From: Paul Floyd Date: Sun, 24 Aug 2025 09:25:51 +0000 (+0200) Subject: illumos syscalls: fd handling (part 4) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a139ed0b3c0af09bf0bcc698072225eb4021a920;p=thirdparty%2Fvalgrind.git illumos syscalls: fd handling (part 4) Almost everything looked OK. Added a couple of POST_newFd_RES macro uses. There are a few functions that create fds other than via RES (like pipe). For these I think that we need to add a POST_newFd(fd) macro, plus in a few places refactor so that RES is available to set the status after ML_(get_next_new_fd). --- diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index a5d34bc5d..f620e85bd 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -2326,10 +2326,8 @@ PRE(sys_readlinkat) if (dfd != VKI_AT_FDCWD && ML_(safe_to_deref)((void *) ARG2, 1) && ((HChar *) ARG2)[0] != '/' - && !ML_(fd_allowed)(dfd, "readlinkat", tid, False)) { + && !ML_(fd_allowed)(dfd, "readlinkat", tid, False)) SET_STATUS_Failure(VKI_EBADF); - return; - } /* Handle the case where readlinkat is looking at /proc/self/path/a.out or /proc//path/a.out. */ @@ -2564,6 +2562,7 @@ PRE(sys_mknodat) POST(sys_mknodat) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "mknodat", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); @@ -7786,6 +7785,7 @@ POST(sys_port) Int opcode = ARG1 & VKI_PORT_CODE_MASK; switch (opcode) { case VKI_PORT_CREATE: + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "port", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE);