summaryrefslogtreecommitdiff
path: root/tools/perf/python
diff options
context:
space:
mode:
authorDanish Khateeb <danishkhateeb03@gmail.com>2026-09-25 16:15:59 -0500
committerThomas Weißschuh <linux@weissschuh.net>2026-09-26 08:43:26 +0200
commit929ea5b3481fdbbb419f3986703280fb2b819504 (patch)
tree9a3a6c1efda87ab091fb101ccdafddc0d20dc8f6 /tools/perf/python
parent00c81514ad49110574e4b9bdbc448551004161f2 (diff)
downloadlinux-next-929ea5b3481fdbbb419f3986703280fb2b819504.tar.gz
linux-next-929ea5b3481fdbbb419f3986703280fb2b819504.zip
tools/nolibc: fix FD_SET(), FD_CLR() and FD_ISSET() on 64-bit
Since commit feaf75658783 ("nolibc: fix fd_set type"), an fd_set is an array of unsigned long, but the FD_* macros still build their masks as an int or an unsigned int: 1 << n in FD_SET(), 1U << n in FD_CLR() and FD_ISSET(), where n is the fd modulo 64 on 64-bit architectures. So: - FD_SET() of an fd with n == 31 sets the bits for n = 31-63, as 1 << 31 is negative and gets sign-extended. - For n >= 32 the shifts are undefined. x86-64, for instance, masks the shift count, so FD_SET(40) and FD_ISSET(40) use the bit of fd 8. - FD_CLR() zero-extends ~(1U << n), so it also clears the bits for n = 32-63, whichever fd it is given. select() on fd 40, for instance, fails with EBADF, or watches fd 8 instead if that one is open. Build the masks from 1UL. Fixes: feaf75658783 ("nolibc: fix fd_set type") Assisted-by: LLM Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com> Link: https://patch.msgid.link/20260925211600.119116-3-danishkhateeb03@gmail.com Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/perf/python')
0 files changed, 0 insertions, 0 deletions