]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 508638 - Self-hosting not working on FreeBSD
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 26 Aug 2025 11:32:07 +0000 (13:32 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 26 Aug 2025 11:32:07 +0000 (13:32 +0200)
NEWS
coregrind/m_syswrap/syswrap-amd64-freebsd.c
coregrind/m_syswrap/syswrap-freebsd.c

diff --git a/NEWS b/NEWS
index 853ba47d2d80274de9cb4e03578f66cf6666c44e..66912d73b5e7fb908e7f9e8066a623433edd939d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -85,6 +85,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 508030  Add several missing syscall hooks to ppc64-linux
 508093  VALGRIND_CLO_CHANGE does not update vex_control
 508154  PRE(sys_fchownat) not handling VKI_AT_FDCWD
+508638  Self-hosting not working on FreeBSD
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 71d1bc8b91d448130e38eeb861379adee3460481..4d3c178481ecd8167a5e491702f882971526f2c7 100644 (file)
@@ -983,12 +983,15 @@ POST(sys_procctl)
 // int mknodat(int fd, const char *path, mode_t mode, dev_t dev);
 PRE(sys_mknodat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*)ARG2;
    PRINT("sys_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4 );
    PRE_REG_READ4(long, "mknodat",
                  int, fd, const char *, path, vki_mode_t, mode, vki_dev_t, dev);
    PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 );
-   if (!ML_(fd_allowed)(ARG1, "mknodat", tid, False))
-      SET_STATUS_Failure(VKI_EBADF);
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ((arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "mknodat", tid, False) )
+         SET_STATUS_Failure(VKI_EBADF);
 }
 
 // SYS_cpuset_getdomain 561
index d92a1a46cd55c02721319e144b4fc5b83b34fe80..7fc96c7c59a19aa8dcabde3a7dd308b2901459e2 100644 (file)
@@ -5332,11 +5332,14 @@ POST(sys_freebsd11_fstatat)
 // int futimesat(int fd, const char *path, const struct timeval times[2]);
 PRE(sys_futimesat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*)ARG2;
    PRINT("sys_futimesat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3);
    PRE_REG_READ3(int, "futimesat",
                  int, fd, const char *, path, struct timeval *, times);
-   if (!ML_(fd_allowed)(ARG1, "futimesat", tid, False))
-      SET_STATUS_Failure(VKI_EBADF);
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ((arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "futimesat", tid, False) )
+         SET_STATUS_Failure(VKI_EBADF);
    if (ARG2 != 0) {
       PRE_MEM_RASCIIZ( "futimesat(path)", ARG2 );
    }
@@ -6189,11 +6192,15 @@ POST(sys_cap_fcntls_get)
 // int bindat(int fd, int s, const struct sockaddr *addr, socklen_t addrlen);
 PRE(sys_bindat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*)ARG2;
    PRINT("sys_bindat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",
          SARG1, SARG2, ARG3, ARG4);
    PRE_REG_READ4(int, "bindat", int, fd, int, s, const struct vki_sockaddr *, name, vki_socklen_t, namelen);
-   if (!ML_(fd_allowed)(ARG1, "bindat", tid, False))
-      SET_STATUS_Failure(VKI_EBADF);
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ((arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "bindat", tid, False) )
+         SET_STATUS_Failure(VKI_EBADF);
+
    PRE_MEM_READ("bindat(name)", ARG3, ARG4);
 }
 
@@ -6201,11 +6208,14 @@ PRE(sys_bindat)
 // int connectat(int fd, int s, const struct sockaddr *name, socklen_t namelen);
 PRE(sys_connectat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*)ARG2;
    PRINT("sys_connectat ( %" FMT_REGWORD "d, %" FMT_REGWORD "dx, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )",
          SARG1, SARG2, ARG3, ARG4);
    PRE_REG_READ4(int, "connectat", int, fd, int, s, const struct vki_sockaddr *, name, vki_socklen_t, namelen);
-   if (!ML_(fd_allowed)(ARG1, "connectat", tid, False))
-      SET_STATUS_Failure(VKI_EBADF);
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ((arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "connectat", tid, False) )
+         SET_STATUS_Failure(VKI_EBADF);
    PRE_MEM_READ("connectat(name)", ARG3, ARG4);
 }
 
@@ -6213,11 +6223,15 @@ PRE(sys_connectat)
 // int chflagsat(int fd, const char *path, unsigned long flags, int atflag);
 PRE(sys_chflagsat)
 {
+   Int arg_1 = (Int)ARG1;
+   const HChar *path = (const HChar*)ARG2;
    PRINT("sys_chglagsat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "d )",
          SARG1, ARG2, ARG3, SARG4);
    PRE_REG_READ4(int, "chflagsat", int, fd, const char *, path, unsigned long, flags, int, atflag);
-   if (!ML_(fd_allowed)(ARG1, "chflagsat", tid, False))
-      SET_STATUS_Failure(VKI_EBADF);
+   if ((ML_(safe_to_deref) (path, 1)) && (path[0] != '/'))
+      if ((arg_1 != VKI_AT_FDCWD) && !ML_(fd_allowed)(arg_1, "chflagsat", tid, False) )
+         SET_STATUS_Failure(VKI_EBADF);
+
    PRE_MEM_RASCIIZ("chflagsat(path)", ARG2);
 }