On 2026-09-25 16:15:57-0500, Danish Khateeb wrote: > Two bugs that only show up on 64-bit architectures: > > - readdir_r() truncates the directory offset to an int. On ext4 it > fails within the first few entries of almost every directory (since > v6.19), or returns the next-to-last entry twice and never the last > one (v6.15 to v6.18). Patch 1. > > - FD_SET(), FD_CLR() and FD_ISSET() build their masks from an int, so > they use the wrong bits for fds 31-63 of each 64-bit word, and > select() on fd 40 fails with EBADF. Patch 2, with a test in patch 3. > > There is no selftest for patch 1: it needs a directory with large > offsets, and nolibc-test only lists /proc/self, whose offsets are > small. I tested it with a small program that lists a directory with > readdir_r() instead. > > Changes in v2: > - Dropped Cc: stable from patches 1 and 2, which are otherwise > unchanged. > - Patch 3: dropped the select() test, and moved the FD_* test to the > stdlib tests, with its helper in the same order as the test cases > (Thomas). It is also shorter: FD_CLR() is now checked on a set > filled with memset(). > - Rebased on nolibc/for-next 6f114ae7b600.
Applied, thanks! (...)

