3 ms·
> I think stat() in the 32bit version of libc is making the 64 bit system call to get the value from the kernel and noticing that it would overflow. I'm not ce
by cesarb 4y ago
> I think stat() in the 32bit version of libc is making the 64 bit system call to get the value from the kernel and noticing that it would overflow.
I'm not certain I'm looking at the correct file, but that does seem to be the case, at least on latest glibc: stat redirects to fstatat(AT_FDCWD) (https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/stat.c;h=32cc0eab62099df7c9ed2885d69ef8d361e32398;hb=HEAD https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/uni...), and fstatat calls a 64-bit system call and fails with EOVERFLOW if any of st_ino, st_size, st_blocks, st_atim, st_mtim, st_ctim wouldn't fit in the 32-bit struct (https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/fstatat.c;h=8926eed2445d3bd38805dec3bfdf34e241da8922;hb=HEAD https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/uni...).
Yes, st_ino too, which means it could also break on a filesystem with large enough inode numbers. Using a 32-bit userspace nowadays seems more problematic the more I look.
- dezgeg 4y ago> Yes, st_ino too, which means it could also break on a filesystem with large enough inode numbers. Yep, been broken for 8 years in some Valve's games: https://github.com/ValveSoftware/Source-1-Games/issues/1685 https://github.com/ValveSoftware/Source-1-Games/issues/1685