]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 508958 - FreeBSD: add getgroups and setgroups wrappers
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 31 Aug 2025 14:32:20 +0000 (16:32 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 31 Aug 2025 14:32:20 +0000 (16:32 +0200)
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 8b7f688f3237c54cff4cd451f69d601bfb9c5a8c..2f77a2dd67c5e75d7b03ee6ce47f8a4e0d7631b9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -93,6 +93,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 508778  syscall-wrapper waitid warns about infop=null
 508779  PRE(sys_prlimit64): reorder check for memory validity
 508869  x86-linux: simplify scalar test output
+508958  FreeBSD: add getgroups and setgroups wrappers
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index f16831933eda777361e7f9e59671e2276fa46601..65f69e85a0be6109ef6ec971cc8455d590abd722 100644 (file)
@@ -107,8 +107,8 @@ DECL_TEMPLATE(freebsd, sys_sbrk) // 69
 // generic mprotect 74
 // generic madvise 75
 // generic mincore 78
-// generic getgroups 79
-// generic setgroups 80
+// generic freebsd14_getgroups 79
+// generic freebsd14_setgroups 80
 // generic getpgrp 81
 // generic setpgid 82
 // generic setitimer 83
@@ -547,6 +547,9 @@ DECL_TEMPLATE(freebsd, sys_exterrctl) // 592
 DECL_TEMPLATE(freebsd, sys_inotify_add_watch_at) // 593
 DECL_TEMPLATE(freebsd, sys_inotify_rm_watch) // 594
 
+// generic getgroups 595
+// generic setgroups 596
+
 DECL_TEMPLATE(freebsd, sys_fake_sigreturn)
 
 #endif   // PRIV_SYSWRAP_FREEBSD_H
index 6679e58fb5047685c204095eedc7e5b7e4c7f6b8..bf7c96a8f27e388bd326d89fc39f8ee190a547be 100644 (file)
@@ -7304,9 +7304,17 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    // obsol vhangup                                        76
    // obsol vlimit                                         77
    GENXY(__NR_mincore,          sys_mincore),           // 78
-   GENXY(__NR_getgroups,        sys_getgroups),         // 79
-
-   GENX_(__NR_setgroups,        sys_setgroups),         // 80
+   #if defined(__NR_freebsd14_getgroups)
+   GENXY(__NR_freebsd14_getgroups, sys_getgroups),      // 79
+   #else
+   GENXY(__NR_getgroups, sys_getgroups),                // 79
+   #endif
+
+   #if defined(__NR_freebsd14_setgroups)
+   GENX_(__NR_freebsd14_setgroups, sys_setgroups),      // 80
+   #else
+   GENX_(__NR_setgroups, sys_setgroups),                // 80
+   #endif
    GENX_(__NR_getpgrp,          sys_getpgrp),           // 81
    GENX_(__NR_setpgid,          sys_setpgid),           // 82
    GENXY(__NR_setitimer,        sys_setitimer),         // 83
@@ -7891,7 +7899,14 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 
    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_inotify_rm_watch, sys_inotify_rm_watch),  // 594
+
+#if defined(__NR_freebsd14_setgroups)
+   GENX_(__NR_setgroups,        sys_setgroups),         // 595
+#endif
+#if defined(__NR_freebsd14_getgroups)
+   GENXY(__NR_getgroups,        sys_getgroups),         // 596
+#endif
 
    BSDX_(__NR_fake_sigreturn,   sys_fake_sigreturn),    // 1000, fake sigreturn
 
index a1514028557e7e382fe04676ad3e184487dd4c03..50df8136aec10fe79c11ba9c1611df7c9f2ac82f 100644 (file)
@@ -28,6 +28,7 @@
 #define VKI_UNISTD_FREEBSD_H
 
 #include "config.h"
+#include <sys/syscall.h>
 
 // this is the syscall format used by e.g., libc functions like 'write'
 // this is the one used 99.999% of the time
 /* obs vhangup                   76 */
 /* obs vlimit                    77 */
 #define __NR_mincore             78
+#if defined(SYS_freebsd_getgroups)
+#define __NR_freebsd14_getgroups 79
+#else
 #define __NR_getgroups           79
+#endif
+#if defined(SYS_freebsd14_setgroups)
+#define __NR_freebsd14_setgroups 80
+#else
 #define __NR_setgroups           80
+#endif
 #define __NR_getpgrp             81
 #define __NR_setpgid             82
 #define __NR_setitimer           83
 #define __NR_inotify_add_watch_at 593
 #define __NR_inotify_rm_watch    594
 
+#if defined(SYS_freebsd_getgroups)
+#define __NR_getgroups           595
+#endif
+#if defined(SYS_freebsd_setgroups)
+#define __NR_setgroups           596
+#endif
+
 #define __NR_fake_sigreturn      1000
 
 #endif /* VKI_UNISTD_FREEBSD_H */
index 0709d1873a63f3adbb0fc28fbf394ec5d47b5d08..c3e700f27cb656d44a9c55c25762aa44afaced9b 100644 (file)
@@ -348,13 +348,23 @@ int main(void)
    GO(SYS_mincore, "3s 1m");
    SY(SYS_mincore, x0, x0+40960, x0); FAIL;
 
-   /* SYS_getgroups               79 */
+   /* SYS_freeebsd14_getgroups    79 */
+#if defined(SYS_freebsd14_getgroups)
+   GO(SYS_freebsd14_getgroups, "2s 1m");
+   SY(SYS_freebsd14_getgroups, x0+1, x0+1); FAIL;
+#else
    GO(SYS_getgroups, "2s 1m");
    SY(SYS_getgroups, x0+1, x0+1); FAIL;
+#endif
 
-   /* SYS_setgroups               80 */
+   /* SYS_freebsd14_setgroups     80 */
+#if defined(SYS_freebsd14_getgroups)
+   GO(SYS_freebsd14_getgroups, "2s 1m");
+   SY(SYS_freebsd14_getgroups, x0+1, x0+1); FAIL;
+#else
    GO(SYS_setgroups, "2s 1m");
    SY(SYS_setgroups, x0+1, x0+1); FAIL;
+#endif
 
    /* SYS_getpgrp                 81 */
    GO(SYS_getpgrp, "0s 0m");
@@ -2169,7 +2179,7 @@ int main(void)
 
    // __FreeBSD_version 1201522
    // __FreeBSD_version 1300045
-   /* SYS___sysctlbyname       570 */
+   /* SYS___sysctlbyname          570 */
    GO(SYS___sysctlbyname, "(getoldlen) 3s 2m");
    SY(SYS___sysctlbyname, x0, x0+1, NULL, x0+1, NULL, x0); FAIL;
 
@@ -2180,7 +2190,7 @@ int main(void)
    SY(SYS___sysctlbyname, x0, x0+1, NULL, NULL, x0+1, x0+2); FAIL;
 
    // FreeBSD 13 (and any backports)
-   /* SYS_shm_open2                      571 */
+   /* SYS_shm_open2               571 */
 #if defined(SYS_shm_open2)
    GO(SYS_shm_open2, " 5s 2m");
    SY(SYS_shm_open2, x0+0xf00c, x0+1, x0+2, x0+3, x0+4); FAIL;
@@ -2235,7 +2245,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS___realpathat                   574 */
+   /* SYS___realpathat            574 */
 #if defined(SYS___realpathat)
    GO(SYS___realpathat, " 5s 2m");
    SY(SYS___realpathat, x0+0xffff, x0, x0, x0+100, x0+2); FAIL;
@@ -2266,14 +2276,14 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_close_range                    575 */
+   /* SYS_close_range             575 */
 #if defined(SYS_close_range)
    GO(SYS_close_range, "3s 0m");
    SY(SYS_close_range, x0+5, x0+10, x0+12345); FAIL;
 #else
 #endif
 
-   /* SYS___specialfd                    577 */
+   /* SYS___specialfd             577 */
 #if defined(SYS___specialfd)
    GO(SYS___specialfd, "3s 1m");
    SY(SYS___specialfd, x0+0xf000, x0+1, x0+10); FAIL;
@@ -2294,7 +2304,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_aio_writev                     578 */
+   /* SYS_aio_writev              578 */
 #if defined(SYS_aio_writev)
    GO(SYS_aio_writev, "1s 1m");
    SY(SYS_aio_writev, x0+1); FAIL;
@@ -2309,7 +2319,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_aio_readv                      579 */
+   /* SYS_aio_readv               579 */
 #if defined(SYS_aio_readv)
    GO(SYS_aio_readv, "1s 1m");
    SY(SYS_aio_readv, x0+1); FAIL;
@@ -2325,7 +2335,7 @@ int main(void)
 #endif
 
     // FreeBSD 15 (and any backports)
-   /* SYS_kqueuex                        583 */
+   /* SYS_kqueuex                 583 */
 #if defined(SYS_kqueuex)
    GO(SYS_kqueuex, " 1s 0m");
    SY(SYS_kqueuex, x0+123); FAIL;
@@ -2336,7 +2346,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_membarrier                     584 */
+   /* SYS_membarrier              584 */
 #if defined(SYS_membarrier)
    GO(SYS_membarrier, " 3s 0m");
    SY(SYS_membarrier, x0+123, x0+456, x0+789); FAIL;
@@ -2353,7 +2363,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_timerfd_create                 585 */
+   /* SYS_timerfd_create          585 */
 #if defined(SYS_timerfd_create)
    GO(SYS_timerfd_create, " 2s 0m");
    SY(SYS_timerfd_create, x0+123, x0+23456); FAIL;
@@ -2367,7 +2377,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_timerfd_gettime                586 */
+   /* SYS_timerfd_gettime         586 */
 #if defined(SYS_timerfd_gettime)
    GO(SYS_timerfd_gettime, " 2s 1m");
    SY(SYS_timerfd_gettime, x0+100, x0); FAIL;
@@ -2385,7 +2395,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_timerfd_settime                587 */
+   /* SYS_timerfd_settime         587 */
 #if defined(SYS_timerfd_settime)
    GO(SYS_timerfd_settime, "4s 2m");
    SY(SYS_timerfd_settime, x0+321, x0, x0+10, x0+5); FAIL;
@@ -2413,7 +2423,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_kcmp                           588 */
+   /* SYS_kcmp                    588 */
 #if defined(SYS_kcmp)
    GO(SYS_kcmp, "5s 0m");
    SY(SYS_kcmp, x0+1, x0+2, x0+3, x0+4, x0+5);
@@ -2436,7 +2446,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
-   /* SYS_getrlimitusage                 589 */
+   /* SYS_getrlimitusage          589 */
 #if defined(SYS_getrlimitusage)
    GO(SYS_getrlimitusage, "3s, 1m");
    SY(SYS_getrlimitusage, x0+3, x0, x0+2);
@@ -2457,6 +2467,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_fchroot                 590 */
 #if defined(SYS_fchroot)
    GO(SYS_fchroot, "1s, 0m");
    SY(SYS_fchroot, x0+1000);
@@ -2467,6 +2478,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_setcred                 591 */
 #if defined(SYS_setcred)
    GO(SYS_setcred, "3s, 1m");
    SY(SYS_setcred, x0+100, x0+3, x0+50);
@@ -2487,6 +2499,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_wxterrctl               592 */
 #if defined(SYS_exterrctl)
    GO(SYS_exterrctl, "3s, 1m");
    SY(SYS_exterrctl, x0, x0+1, x0+1);
@@ -2507,6 +2520,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_inotify_add_watch_at    593 */
 #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);
@@ -2527,6 +2541,7 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_inotify_rm_watch        594 */
 #if defined(SYS_inotify_rm_watch)
    GO(SYS_inotify_rm_watch, "2s, 0m");
    SY(SYS_inotify_rm_watch, x0+1000, x0+1000);
@@ -2540,6 +2555,42 @@ int main(void)
    FAKE_SY("\n");
 #endif
 
+   /* SYS_getgroups               595 */
+#if defined(SYS_freebsd14_getgroups)
+   GO(SYS_getgroups, "2s 1m");
+   SY(SYS_getgroups, x0+1, x0+1); FAIL;
+#else
+   FAKE_GO("595:           SYS_getgroups 2s 1m");
+   FAKE_SY("Syscall param getgroups(size) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param getgroups(list) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param getgroups(list) 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
+
+   /* SYS_setgroups               596 */
+#if defined(SYS_freebsd14_getgroups)
+   GO(SYS_getgroups, "2s 1m");
+   SY(SYS_getgroups, x0+1, x0+1); FAIL;
+#else
+   FAKE_GO("596:           SYS_setgroups 2s 1m");
+   FAKE_SY("Syscall param setgroups(size) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param setgroups(list) contains uninitialised byte(s)\n");
+   FAKE_SY("   ...\n");
+   FAKE_SY("\n");
+   FAKE_SY("Syscall param setgroups(list) 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
+
    /* SYS_exit                    1 */
    GO(SYS_exit, "1s 0m");
    SY(SYS_exit, x0); FAIL;
index 882433a92d3c5e5ccffb8172dacb4084bced10fd..166552caf6af0457b8b6f2c232527c85db61e0f3 100644 (file)
@@ -5825,6 +5825,32 @@ Syscall param sys_inotify_rm_watch(fd) contains uninitialised byte(s)
 Syscall param sys_inotify_rm_watch(wd) contains uninitialised byte(s)
    ...
 
+---------------------------------------------------------
+595:           SYS_getgroups 2s 1m
+---------------------------------------------------------
+Syscall param getgroups(size) contains uninitialised byte(s)
+   ...
+
+Syscall param getgroups(list) contains uninitialised byte(s)
+   ...
+
+Syscall param getgroups(list) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+596:           SYS_setgroups 2s 1m
+---------------------------------------------------------
+Syscall param setgroups(size) contains uninitialised byte(s)
+   ...
+
+Syscall param setgroups(list) contains uninitialised byte(s)
+   ...
+
+Syscall param setgroups(list) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
 ---------------------------------------------------------
   1:                SYS_exit 1s 0m
 ---------------------------------------------------------
index 20d8d3ca72fc34207bd2f03f52bac24e58951b7d..52c7ce8c39442a0a7e6eff4d9e6be4294ef98002 100644 (file)
@@ -5897,6 +5897,32 @@ Syscall param sys_inotify_rm_watch(fd) contains uninitialised byte(s)
 Syscall param sys_inotify_rm_watch(wd) contains uninitialised byte(s)
    ...
 
+---------------------------------------------------------
+595:           SYS_getgroups 2s 1m
+---------------------------------------------------------
+Syscall param getgroups(size) contains uninitialised byte(s)
+   ...
+
+Syscall param getgroups(list) contains uninitialised byte(s)
+   ...
+
+Syscall param getgroups(list) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+---------------------------------------------------------
+596:           SYS_setgroups 2s 1m
+---------------------------------------------------------
+Syscall param setgroups(size) contains uninitialised byte(s)
+   ...
+
+Syscall param setgroups(list) contains uninitialised byte(s)
+   ...
+
+Syscall param setgroups(list) points to unaddressable byte(s)
+   ...
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
 ---------------------------------------------------------
   1:                SYS_exit 1s 0m
 ---------------------------------------------------------