Problems of 64-bit code in real programs: what about Linux?

    Talking about 64-bit errors waiting for programmers to migrate their programs, I often hear reproaches: “Well, yes, this is your Windows, it’s such a ... Well, there’s no problem with Linux with 64-bit code ".

    “Well, no, my curious reader.”

    Today's post about a 64-bit error in the Linux kernel.

    A wonderful site with a kernel tracking system (bug tracking system) contains a description of bug 16603 (send of data> 4 GB fails on 64 bit systems). The essence of the problem is simple: “Sending data using the Linux send () function results in an error if the data size is too large. The function from glibc looks like this:

    ssize_t send (int sockfd, const void * buf, size_t len, int flags);

    Everything is correct, the size is passed as memsize-type size_t . However, this argument is stored in the msgheader structure, after which the lines go inside the tcp_sendmsg function:

    while (--iovlen> = 0) {
                    int seglen = iov-> iov_len;
                    unsigned char __user * from = iov-> iov_base;

    Here the length is already stored in int, which, of course, is no good. That is, sending with a send () block of 5 gigabytes will send only 1 gigabyte, and sending a block of 4 gigabytes will not produce anything (due to "rounding" to zero).

    Of course, the workaround is clear - specify a length of not more than 0x8000000, but this is a mistake and of course it must be corrected.

    Yes, and this is not a nineties example. The bug was opened in August 2010, it belongs to the kernel version 2.5. And while (October 11, 2010) is not closed. And you say there are no 64-bit problems in Linux ...

    Also popular now: