Subject: bug#25149: md5sum fails with message "Invalid argument" on 4, 294, 967, 295-byte files in FAT32

From: Pádraig Brady <[email-masked]>
Date: Fri, 9 Dec 2016 18:11:42 +0000

On 09/12/16 15:45, Jaime Gaspar wrote:
> --- Bug ---
> In a FAT32 file system, if one runs md5sum on a 4,294,967,294-byte file (one byte less than the maximum file size) it succeeds, but if one runs md5sum on a 4,294,967,295-byte file (the maximum file size) it fails with error message "Invalid argument".
> 
> --- How to reproduce the bug ---
> Create a FAT32 file system in a file "tmp.fs":
>    truncate -s 9G tmp.fs
>    mkfs.vfat -F 32 tmp.fs
> Mount at "/tmp/mounted_tmp/" the file system in file "tmp.fs":
>    sudo mkdir /tmp/mounted_tmp/
>    sudo mount -o loop,rw,uid=1000,gid=1000 tmp.fs /tmp/mounted_tmp/
> Create two files in "/tmp/mounted_tmp/", file "file_1" with 4,294,967,294 bytes and file "file_2" with 4,294,967,295 bytes:
>    cd /tmp/mounted_tmp/
>    truncate -s 4294967294 file_1
>    truncate -s 4294967295 file_2
> Run md5sum on the two files "file_1" and "file_2":
>    md5sum file_1
>    md5sum file_2
> The outputs should be respectively (notice that the second output is an error message):
>    541249e3205af07b4a03f891185f64a0  file_1
>    md5sum: file_2: Invalid argument
> Unmount the file system at "/tmp/mounted_tmp/":
>    cd ..
>    sudo umount /tmp/mounted_tmp/
>    sudo rmdir /tmp/mounted_tmp/
> Remove the file "tmp.fs".
> 
> --- Notes ---
> Tested with md5sum 8.25 running on an updated Ubuntu 16.10 with kernel 4.8.0-30-generic.
> The same bug affects sha1sum, sha224sum, sha256sum, sha384sum, and sha512sum, but not crc32.

I can't repro this with any md5sum version on 4.2.5-300.fc23.x86_64
So I'm guessing a kernel regression.
Can you strace -o /tmp/md5sum.strace md5sum file_2,
and look towards the end of the strace file to identify the syscall returning EINVAL?
In any case I'd direct the issue towards the kernel folks.

thanks,
Pádraig