]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
illumos syscalls: fd handling (part 4)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 24 Aug 2025 09:25:51 +0000 (11:25 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 24 Aug 2025 09:25:51 +0000 (11:25 +0200)
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).

coregrind/m_syswrap/syswrap-solaris.c

index a5d34bc5d516287e06fbfaed9012dda6c7c4c792..f620e85bd7aa01999f78bbfdb69ef3f77d27ac8b 100644 (file)
@@ -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/<pid>/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);