]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Illumos: increase coverage of --modify-fds syscalls
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 17 Apr 2025 19:26:24 +0000 (21:26 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 17 Apr 2025 19:26:24 +0000 (21:26 +0200)
It looks like Solaris/Illumos is missing some F_DUP* coverage
and we aren't handling syscalls that reaturn 2 fds (pipe, socketpair).
Otherwise this should cover most Illumos cases at least.

coregrind/m_syswrap/syswrap-generic.c
coregrind/m_syswrap/syswrap-solaris.c
coregrind/m_syswrap/syswrap-x86-solaris.c

index 1ab494c84007841660d90c85e74c162a73438009..82a682a5ce554935e03a25c78ecd90a18be827b8 100644 (file)
@@ -1814,6 +1814,7 @@ ML_(generic_POST_sys_socketpair) ( ThreadId tid,
    Int fd1 = ((Int*)arg3)[0];
    Int fd2 = ((Int*)arg3)[1];
    vg_assert(!sr_isError(res)); /* guaranteed by caller */
+   // @todo PJF this needs something like POST_newFd_RES for the two fds?
    POST_MEM_WRITE( arg3, 2*sizeof(int) );
    if (!ML_(fd_allowed)(fd1, "socketcall.socketpair", tid, True) ||
        !ML_(fd_allowed)(fd2, "socketcall.socketpair", tid, True)) {
index 6b61a0e0dc71cfac9000f2d478fe3d2bbc7bdf04..a5d34bc5d516287e06fbfaed9012dda6c7c4c792 100644 (file)
@@ -2492,6 +2492,7 @@ PRE(sys_pipe)
 POST(sys_pipe)
 {
    Int p0, p1;
+   // @todo PJF this needs something like POST_newFd_RES for the two fds?
 
 #if defined(SOLARIS_NEW_PIPE_SYSCALL)
    int *fds = (int*)ARG1;
@@ -4074,8 +4075,11 @@ PRE(sys_fcntl)
 
 POST(sys_fcntl)
 {
+   // @todo PJF we're missing
+   // F_DUP2FD_CLOEXEC F_DUP2FD_CLOFORK F_DUPFD_CLOFORK F_DUP3FD
    switch (ARG2 /*cmd*/) {
    case VKI_F_DUPFD:
+      POST_newFd_RES;
       if (!ML_(fd_allowed)(RES, "fcntl(F_DUPFD)", tid, True)) {
          VG_(close)(RES);
          SET_STATUS_Failure(VKI_EMFILE);
@@ -4084,6 +4088,7 @@ POST(sys_fcntl)
       break;
 
    case VKI_F_DUPFD_CLOEXEC:
+      POST_newFd_RES;
       if (!ML_(fd_allowed)(RES, "fcntl(F_DUPFD_CLOEXEC)", tid, True)) {
          VG_(close)(RES);
          SET_STATUS_Failure(VKI_EMFILE);
@@ -4092,6 +4097,7 @@ POST(sys_fcntl)
       break;
 
    case VKI_F_DUP2FD:
+      POST_newFd_RES;
       if (!ML_(fd_allowed)(RES, "fcntl(F_DUP2FD)", tid, True)) {
          VG_(close)(RES);
          SET_STATUS_Failure(VKI_EMFILE);
@@ -4258,6 +4264,7 @@ PRE(sys_openat)
 
 POST(sys_openat)
 {
+   POST_newFd_RES;
    if (!ML_(fd_allowed)(RES, "openat", tid, True)) {
       VG_(close)(RES);
       SET_STATUS_Failure(VKI_EMFILE);
@@ -9555,7 +9562,13 @@ POST(sys_door)
 
    switch (ARG6 /*subcode*/) {
    case VKI_DOOR_CREATE:
-      door_record_server(tid, ARG1, RES);
+      POST_newFd_RES;
+      if (!ML_(fd_allowed)(RES, "door_create", tid, True)) {
+         VG_(close)(RES);
+         SET_STATUS_Failure( VKI_EMFILE );
+      } else {
+         door_record_server(tid, ARG1, RES);
+      }
       break;
    case VKI_DOOR_REVOKE:
       door_record_revoke(tid, ARG1);
index be3662511225c1265c27338131729e85d727ac9e..59c36c18528223b7d849df00c6ac3200e8d1f96d 100644 (file)
@@ -971,6 +971,7 @@ PRE(sys_open64)
 
 POST(sys_open64)
 {
+   POST_newFd_RES;
    if (!ML_(fd_allowed)(RES, "open64", tid, True)) {
       VG_(close)(RES);
       SET_STATUS_Failure(VKI_EMFILE);