]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 506499 - Unhandled syscall 592 (exterrctl - FreeBSD)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 12 Jul 2025 20:23:05 +0000 (22:23 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 12 Jul 2025 20:23:05 +0000 (22:23 +0200)
Also add wrapers for inotify_add_watch_at and inotify_rm_watch

No specific tests for these yet.

NEWS
coregrind/m_syswrap/priv_syswrap-freebsd.h
coregrind/m_syswrap/syswrap-freebsd.c
include/vki/vki-scnums-freebsd.h
memcheck/tests/freebsd/scalar.c
memcheck/tests/freebsd/scalar.stderr.exp
memcheck/tests/freebsd/scalar.stderr.exp-x86

diff --git a/NEWS b/NEWS
index ce162cb18ce65bf7231ec04f51087cb19a14e9d2..73488cbc172d8266107b577d3f1ec8a08176b311 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
         AMD64_GET_TLSBASE
 505228  Wrap linux specific mseal syscall
 502968  Wrap linux specific syscalls 457 (listmount) and 458 (statmount)
+506499  Unhandled syscall 592 (exterrctl - FreeBSD
 506795  Better report which clone flags are problematic
 
 To see details of a given bug, visit
index f8d404239d50f90fa3b704486b0a035f6bc6cc00..f16831933eda777361e7f9e59671e2276fa46601 100644 (file)
@@ -543,6 +543,10 @@ DECL_TEMPLATE(freebsd, sys_getrlimitusage) // 589
 DECL_TEMPLATE(freebsd, sys_fchroot) // 590
 DECL_TEMPLATE(freebsd, sys_setcred) // 591
 
+DECL_TEMPLATE(freebsd, sys_exterrctl) // 592
+DECL_TEMPLATE(freebsd, sys_inotify_add_watch_at) // 593
+DECL_TEMPLATE(freebsd, sys_inotify_rm_watch) // 594
+
 DECL_TEMPLATE(freebsd, sys_fake_sigreturn)
 
 #endif   // PRIV_SYSWRAP_FREEBSD_H
index 4ce860976c1fd3852993a461db5415737d3906ee..79e30f7d37ee04174e81d280eb24d9f067ec1d2c 100644 (file)
@@ -4864,8 +4864,8 @@ PRE(sys_kmq_notify)
 // int kmq_unlink(const char *path);
 PRE(sys_kmq_unlink)
 {
-   PRINT("sys_kmq_unlink ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1);
-   PRE_REG_READ1(int, "mq_unlink", const char *, name);
+   PRINT("sys_kmq_unlink ( %#" FMT_REGWORD "x(%s) )", ARG1,(HChar *)ARG1);
+   PRE_REG_READ1(int, "mq_unlink", const HChar *, name);
    PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1 );
 }
 
@@ -7054,7 +7054,7 @@ POST(sys_getrlimitusage)
 // int fchroot(int fd);
 PRE(sys_fchroot)
 {
-   PRINT("sys_fchroot(%ld)", ARG1);
+   PRINT("sys_fchroot(%" FMT_REGWORD "d)", ARG1);
    PRE_REG_READ1(int, "fchroot", int, fd);
 
    /* Be strict. */
@@ -7066,11 +7066,55 @@ PRE(sys_fchroot)
 // int setcred(u_int flags, const struct setcred *wcred, size_t size);
 PRE(sys_setcred)
 {
-   PRINT("sys_setcred(%ld, %#" FMT_REGWORD "x, %lu)", ARG1, ARG2, ARG3);
+   PRINT("sys_setcred(%" FMT_REGWORD "d, %#" FMT_REGWORD "x, %" FMT_REGWORD "u)", ARG1, ARG2, ARG3);
    PRE_REG_READ3(int, "setcred", u_int, flags, const struct setcred*, wcred, size_t, size);
    PRE_MEM_READ("setcred(wcred)", ARG2, sizeof(struct vki_setcred));
 }
 
+// SYS_exterrctl
+// int exterrctl(u_int op, u_int flags, _In_reads_bytes_(4) void *ptr
+PRE(sys_exterrctl)
+{
+   PRINT("sys_exterrctl(%" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x)",
+         ARG1, ARG2, ARG3);
+   PRE_REG_READ3(int, "exterrctl", u_int, op, u_int, flags, void*, ptr);
+   // the void* points to struct uexterror which at the time of writing has 10 fields
+   // but this syscall just turns this feature on and off and it's only th first 4 bytes
+   // for the version that gets checked
+   PRE_MEM_READ("exterrctl(ptr)", ARG3, 4);
+}
+
+// SYS_inotify_add_watch_at
+// int inotify_add_watch_at(int fd, int dfd, _In_z_ const char *path, uint32_t mask);
+PRE(sys_inotify_add_watch_at)
+{
+   PRINT("sys_inotify_add_watch_at(%" FMT_REGWORD "d, %" FMT_REGWORD "d, %" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x)", SARG1, SARG2, ARG3, (HChar*)ARG3, ARG4);
+   PRE_REG_READ4(int, "inotify_add_watch_at", int, fd, int, dfd, const char*, path, uint32_t, mask);
+   PRE_MEM_RASCIIZ("inotify_add_watch_at(path)", ARG3);
+   if (!ML_(fd_allowed)(ARG1, "inotify_add_watch_at", tid, False)) {
+      SET_STATUS_Failure( VKI_EBADF );
+   }
+   if (ARG2 != VKI_AT_FDCWD) {
+      if (!ML_(fd_allowed)(ARG2, "inotify_add_watch_at", tid, False)) {
+         SET_STATUS_Failure( VKI_EBADF );
+      }
+   }
+}
+
+// SYS_inotify_rm_watch
+// int inotify_rm_watch(int fd, int wd);
+PRE(sys_inotify_rm_watch)
+{
+   PRINT("sys_inotify_rm_watch(%" FMT_REGWORD "d, %" FMT_REGWORD "d)", SARG1, SARG2);
+   PRE_REG_READ2(int, "sys_inotify_rm_watch", int, fd, int, wd);
+   if (!ML_(fd_allowed)(ARG1, "inotify_rm_watch", tid, False)) {
+      SET_STATUS_Failure( VKI_EBADF );
+   }
+   // PJF I don't think that this can be AT_FDCWD
+   if (!ML_(fd_allowed)(ARG2, "inotify_rm_watch", tid, False)) {
+      SET_STATUS_Failure( VKI_EBADF );
+   }
+}
 
 #undef PRE
 #undef POST
@@ -7768,6 +7812,10 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDX_(__NR_fchroot,          sys_fchroot),           // 590
    BSDX_(__NR_setcred,          sys_setcred),           // 591
 
+   BSDX_(__NR_exterrctl,        sys_exterrctl),         // 592
+   BSDX_(__NR_inotify_add_watch_at, sys_inotify_add_watch_at), // 593
+   BSDX_(__NR_inotify_rm_watch, sys_inotify_rm_watch),  // 593
+
    BSDX_(__NR_fake_sigreturn,   sys_fake_sigreturn),    // 1000, fake sigreturn
 
 };
index a92abb9a1542e66ea4ab9335c5833495a3600d8d..a1514028557e7e382fe04676ad3e184487dd4c03 100644 (file)
 #define __NR_fchroot             590
 #define __NR_setcred             591
 
+#define __NR_exterrctl           592
+#define __NR_inotify_add_watch_at 593
+#define __NR_inotify_rm_watch    594
+
 #define __NR_fake_sigreturn      1000
 
 #endif /* VKI_UNISTD_FREEBSD_H */
index bae3d943bc1f23ead3133e1490de01df4ad05139..ce76ffdb2129ff82fd5f566a713afc3636329ad3 100644 (file)
@@ -2479,6 +2479,59 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+#if defined(SYS_exterrctl)
+   GO(SYS_exterrctl, "3s, 1m");
+   SY(SYS_exterrctl, x0, x0+1, x0+1);
+#else
+   FAKE_GO("592:           SYS_exterrctl 3s, 1m");
+   FAKE_SY("Syscall param exterrctl(op) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param exterrctl(flags) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param exterrctl(ptr) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param exterrctl(ptr) points to unaddressable byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\ Address 0x........ is not stack'd, malloc'd or (recently) free'd\n");
+   FAKE_SY("\n");
+#endif
+
+#if defined(SYS_inotify_add_watch_at)
+   GO(SYS_inotify_add_watch_at, "3s, 1m");
+   SY(SYS_inotify_add_watch_at, x0, x0+1, x0+1);
+#else
+   FAKE_GO("593:SYS_inotify_add_watch_at 3s, 1m");
+   FAKE_SY("Syscall param inotify_add_watch_at(fd) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param inotify_add_watch_at(dfd) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param inotify_add_watch_at(path) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param inotify_add_watch_at(path) points to unaddressable byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY(" Address 0x........ is not stack'd, malloc'd or (recently) free'd\n");
+   FAKE_SY("\n");
+#endif
+
+#if defined(SYS_inotify_rm_watch)
+   GO(SYS_inotify_rm_watch, "2s, 0m");
+   SY(SYS_inotify_rm_watch, x0+1000, x0+1000);
+#else
+   FAKE_GO("594:    SYS_inotify_rm_watch 2s, 0m");
+   FAKE_SY("Syscall param sys_inotify_rm_watch(fd) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param sys_inotify_rm_watch(wd) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+#endif
+
    /* SYS_exit                    1 */
    GO(SYS_exit, "1s 0m");
    SY(SYS_exit, x0); FAIL;
index ae8adcd1b4888e345ea2de97ec6f376f8ec1c6c8..dbe79c6e84efccdcd4b9ce8ebaa9513b005328b4 100644 (file)
@@ -5746,6 +5746,47 @@ Syscall param setcred(wcred) points to unaddressable byte(s)
    ...
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
+---------------------------------------------------------
+592:           SYS_exterrctl 3s, 1m
+---------------------------------------------------------
+Syscall param exterrctl(op) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(flags) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(ptr) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(ptr) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+593:SYS_inotify_add_watch_at 3s, 1m
+---------------------------------------------------------
+Syscall param inotify_add_watch_at(fd) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(dfd) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(path) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(path) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+594:    SYS_inotify_rm_watch 2s, 0m
+---------------------------------------------------------
+Syscall param sys_inotify_rm_watch(fd) contains uninitialised byte(s)
+   ...
+
+Syscall param sys_inotify_rm_watch(wd) contains uninitialised byte(s)
+   ...
+
 ---------------------------------------------------------
   1:                SYS_exit 1s 0m
 ---------------------------------------------------------
index 47beb3dcecb3918ccff2b3385df0583cdae935a3..ea5abb9c613ef0330e86bdf8c9931b42314a5d4c 100644 (file)
@@ -5818,6 +5818,47 @@ Syscall param setcred(wcred) points to unaddressable byte(s)
    ...
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
+---------------------------------------------------------
+592:           SYS_exterrctl 3s, 1m
+---------------------------------------------------------
+Syscall param exterrctl(op) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(flags) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(ptr) contains uninitialised byte(s)
+   ...
+
+Syscall param exterrctl(ptr) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+593:SYS_inotify_add_watch_at 3s, 1m
+---------------------------------------------------------
+Syscall param inotify_add_watch_at(fd) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(dfd) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(path) contains uninitialised byte(s)
+   ...
+
+Syscall param inotify_add_watch_at(path) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+594:    SYS_inotify_rm_watch 2s, 0m
+---------------------------------------------------------
+Syscall param sys_inotify_rm_watch(fd) contains uninitialised byte(s)
+   ...
+
+Syscall param sys_inotify_rm_watch(wd) contains uninitialised byte(s)
+   ...
+
 ---------------------------------------------------------
   1:                SYS_exit 1s 0m
 ---------------------------------------------------------