📜 ⬆️ ⬇️

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

Talking about 64-bit errors that await programmers when migrating their programs, I often hear reproaches: “Well, yes, this is your Windows, it’s so ... It's good that in Linux with a 64-bit problem code, yes-a-a-avno anymore ".

"But no, my inquisitive reader."

Today's post about a 64-bit error in the Linux kernel.
A wonderful site with a bug tracking system for kernel developers describes bug 16603 (send of data> 4 GB fails on 64 bit systems). The essence of the problem is simple: “Sending data using the Linux function send () 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 transferred as size_t memsize-type. However, this argument is stored in the msgheader structure, after which the lines inside the tcp_sendmsg function are:

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

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

Of course, the workaround is understandable - specify a length of no more than 0x8000000, but this is a mistake and, of course, it should be corrected.

Yes, and this is not an example of the nineties. Bug opened in August 2010, refers 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 ...

Source: https://habr.com/ru/post/105984/

All Articles