]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 509258 - FreeBSD: add jail_attach_jd and jail_remove_jd syscall wrappers
authorPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 8 Sep 2025 05:31:02 +0000 (07:31 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 8 Sep 2025 05:31:02 +0000 (07:31 +0200)
NEWS
coregrind/m_syswrap/priv_syswrap-freebsd.h
coregrind/m_syswrap/syswrap-freebsd.c
include/vki/vki-scnums-freebsd.h

diff --git a/NEWS b/NEWS
index 85b7a17b1f50149a7e9654523fe004a1e5c23df7..0158a23af838b1a56d5adaac1a639826823e1316 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -97,6 +97,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 509103  Fix tests/arm64/bug484935.c build with "-O2 -flto -ffat-lto-objects"
 509107  memcheck/tests/duplicate_align_size_errors.cpp fails
 509139  Update BadSize error messages
+509258  FreeBSD: add jail_attach_jd and jail_remove_jd syscall wrappers
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index b30cce4e869e6045aa0ecfad5d6a862822c73387..8ac3b8e9204a81701dd5689b8fce79c7c1a1a317 100644 (file)
@@ -550,6 +550,9 @@ DECL_TEMPLATE(freebsd, sys_inotify_rm_watch) // 594
 // generic getgroups 595
 // generic setgroups 596
 
+DECL_TEMPLATE(freebsd, sys_jail_attach_jd) // 597
+DECL_TEMPLATE(freebsd, sys_jail_remove_jd) // 598
+
 DECL_TEMPLATE(freebsd, sys_fake_sigreturn)
 
 #endif   // PRIV_SYSWRAP_FREEBSD_H
index ef4712391f809c8739c3287be9e27feaaa0b6ec7..eb8a16058667b8c859f0ea71290be8f12d005754 100644 (file)
@@ -7148,7 +7148,7 @@ PRE(sys_fchroot)
       SET_STATUS_Failure(VKI_EBADF);
 }
 
-// SYS_setcred
+// SYS_setcred 591
 // int setcred(u_int flags, const struct setcred *wcred, size_t size);
 PRE(sys_setcred)
 {
@@ -7157,7 +7157,7 @@ PRE(sys_setcred)
    PRE_MEM_READ("setcred(wcred)", ARG2, sizeof(struct vki_setcred));
 }
 
-// SYS_exterrctl
+// SYS_exterrctl 592
 // int exterrctl(u_int op, u_int flags, _In_reads_bytes_(4) void *ptr
 PRE(sys_exterrctl)
 {
@@ -7170,7 +7170,7 @@ PRE(sys_exterrctl)
    PRE_MEM_READ("exterrctl(ptr)", ARG3, 4);
 }
 
-// SYS_inotify_add_watch_at
+// SYS_inotify_add_watch_at 593
 // int inotify_add_watch_at(int fd, int dfd, _In_z_ const char *path, uint32_t mask);
 PRE(sys_inotify_add_watch_at)
 {
@@ -7180,12 +7180,12 @@ PRE(sys_inotify_add_watch_at)
    ML_(fd_at_check_allowed)(SARG1, (const HChar*)ARG2, "inotify_add_watch_at", tid, status);
 }
 
-// SYS_inotify_rm_watch
+// SYS_inotify_rm_watch 594
 // 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);
+   PRE_REG_READ2(int, "inotify_rm_watch", int, fd, int, wd);
    if (!ML_(fd_allowed)(ARG1, "inotify_rm_watch", tid, False)) {
       SET_STATUS_Failure( VKI_EBADF );
    }
@@ -7195,6 +7195,34 @@ PRE(sys_inotify_rm_watch)
    }
 }
 
+// __NR_setgroups 595
+// generic
+
+// __NR_getgroups 596
+// generic
+
+// __NR_jail_attach_jd 597
+// int jail_attach_jd(int fd);
+PRE(sys_jail_attach_jd)
+{
+    PRINT("sys_jail_attach_jd(%" FMT_REGWORD"d)", SARG1);
+    PRE_REG_READ1(int, "jail_attach_jd", int, fd);
+
+    if (!ML_(fd_allowed)(ARG1, "jail_attach_id", tid, False))
+       SET_STATUS_Failure(VKI_EBADF);
+}
+
+// __NR_jail_remove_jd 598
+// int jail_remove_jd(int fd);
+PRE(sys_jail_remove_jd)
+{
+    PRINT("sys_jail_remove_jd(%" FMT_REGWORD"d)", SARG1);
+    PRE_REG_READ1(int, "jail_remove_jd", int, fd);
+
+    if (!ML_(fd_allowed)(ARG1, "jail_remove_id", tid, False))
+       SET_STATUS_Failure(VKI_EBADF);
+}
+
 #undef PRE
 #undef POST
 
@@ -7910,6 +7938,9 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    GENXY(__NR_getgroups,        sys_getgroups),         // 596
 #endif
 
+    BSDX_(__NR_jail_attach_jd,  sys_jail_attach_jd),    // 597
+    BSDX_(__NR_jail_remove_jd,  sys_jail_remove_jd),    // 598
+
    BSDX_(__NR_fake_sigreturn,   sys_fake_sigreturn),    // 1000, fake sigreturn
 
 };
index 1f2df9be4023167b8d597df187781404fc094682..8af22bde7cf64788725f599a5720275e946778e2 100644 (file)
 #define __NR_setgroups           596
 #endif
 
+#define __NR_jail_attach_jd      597
+#define __NR_jail_remove_jd      598
+
 #define __NR_fake_sigreturn      1000
 
 #endif /* VKI_UNISTD_FREEBSD_H */