Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It was brought to my attention that this bug from 2018 was still unresolved: 32 bit emulators like QEMU were given 64 bit hashes when running 32 bit emulation on 64 bit systems. This adds a flag to the fcntl() F_GETFD and F_SETFD operations to set the underlying filesystem into 32bit mode even if the file handle was opened using 64bit mode without the compat syscalls. Programs that need the 32 bit file system behavior need to issue a fcntl() system call such as in this example: #define FD_32BIT_MODE 2 int main(int argc, char** argv) { DIR* dir; int err; int mode; int fd; dir = opendir("/boot"); fd = dirfd(dir); mode = fcntl(fd, F_GETFD); mode |= FD_32BIT_MODE; err = fcntl(fd, F_SETFD, mode); if (err) { printf("fcntl() failed! err=%d\n", err); return 1; } printf("dir=%p\n", dir); printf("readdir(dir)=%p\n", readdir(dir)); printf("errno=%d: %s\n", errno, strerror(errno)); return 0; } This can be pretty hard to test since C libraries and linux userspace security extensions aggressively filter the parameters that are passed down and allowed to commit into actual system calls. Cc: Florian Weimer <[email protected]> Cc: Peter Maydell <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Eric Blake <[email protected]> Reported-by: 罗勇刚(Yonggang Luo) <[email protected]> Suggested-by: Theodore Ts'o <[email protected]> Link: https://bugs.launchpad.net/qemu/+bug/1805913 Link: https://lore.kernel.org/lkml/[email protected]/ Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=205957 Signed-off-by: Linus Walleij <[email protected]>
- Loading branch information