* Linus Walleij:
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.
The personality(2) system call supports to let processes indicate that they are 32 bit Linux to the kernel. This was suggested by Teo in the original thread, so I just wired it up and it solves the problem.
Programs that need the 32 bit hash only need to issue the personality(PER_LINUX32) call and things start working.
I made a test program like this:
#include <dirent.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/personality.h>
int main(int argc, char** argv) { DIR* dir; personality(PER_LINUX32); dir = opendir("/boot"); printf("dir=%p\n", dir); printf("readdir(dir)=%p\n", readdir(dir)); printf("errno=%d: %s\n", errno, strerror(errno)); return 0; }
This was compiled with an ARM32 toolchain from Bootlin using glibc 2.28 and thus suffering from the bug.
Just be sure: Is it possible to move the PER_LINUX32 setting into QEMU? (I see why not.)
However, this does not solve the issue with network file systems and other scenarios. I still think need to add a workaround to the glibc implementation.