From f7bccf55135a7459e6c3d088a3be6b05c2856903 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 18 Apr 2023 01:15:01 +0200 Subject: [PATCH] Fix pledge rpath support for old getdents syscall (#804) The rpath pledge as currently implemented in cosmopolitan does not allow for usage of the old getdents syscall (0x4e), which is different from the newer getdents syscall (0xd9) solely in that it does not support 64-bit filesystems. This means that, for example, old statically linked binaries cannot use `readdir` and other such functions which use this syscall instead of the more modern one, even though there is no threat in allowing that syscall alongside the more modern one (except that the binary may have issues with 64-bit filesystems, but that's a separate problem). This patch fixes this. --- libc/calls/pledge-linux.c | 2 ++ libc/sysv/consts/nrlinux.h | 1 + 2 files changed, 3 insertions(+) diff --git a/libc/calls/pledge-linux.c b/libc/calls/pledge-linux.c index 7e29bd67a..368a91113 100644 --- a/libc/calls/pledge-linux.c +++ b/libc/calls/pledge-linux.c @@ -292,6 +292,7 @@ static const struct thatispacked SyscallName { {__NR_linux_epoll_wait, "epoll_wait"}, // {__NR_linux_epoll_ctl, "epoll_ctl"}, // {__NR_linux_getdents, "getdents"}, // + {__NR_linux_oldgetdents, "oldgetdents"}, // {__NR_linux_set_tid_address, "set_tid_address"}, // {__NR_linux_restart_syscall, "restart_syscall"}, // {__NR_linux_semtimedop, "semtimedop"}, // @@ -582,6 +583,7 @@ static const uint16_t kPledgeRpath[] = { __NR_linux_statfs, // __NR_linux_fstatfs, // __NR_linux_getdents, // + __NR_linux_oldgetdents, // }; static const uint16_t kPledgeWpath[] = { diff --git a/libc/sysv/consts/nrlinux.h b/libc/sysv/consts/nrlinux.h index 97f5dd55b..1b76b0595 100644 --- a/libc/sysv/consts/nrlinux.h +++ b/libc/sysv/consts/nrlinux.h @@ -209,6 +209,7 @@ #define __NR_linux_epoll_wait 0x00e8 #define __NR_linux_epoll_ctl 0x00e9 #define __NR_linux_getdents 0x00d9 +#define __NR_linux_oldgetdents 0x004e #define __NR_linux_set_tid_address 0x00da #define __NR_linux_restart_syscall 0x00db #define __NR_linux_semtimedop 0x00dc