|
From: Paul F. <pa...@so...> - 2026-03-03 13:02:47
|
https://sourceware.org/cgit/valgrind/commit/?id=f26704c0fe412d002ef280cbc9a3b42381469c3a commit f26704c0fe412d002ef280cbc9a3b42381469c3a Author: Paul Floyd <pj...@wa...> Date: Tue Mar 3 14:02:16 2026 +0100 Bug 390754 - unhandled amd64-darwin syscall: unix:216 (open_dprotected_np) Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-darwin.h | 2 +- coregrind/m_syswrap/syswrap-darwin.c | 82 ++++++++++++++++++++++++++++--- include/vki/vki-scnums-darwin.h | 2 +- 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index eee47e3402..57184fac95 100644 --- a/NEWS +++ b/NEWS @@ -54,6 +54,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 233298 MEMPOOL_FREE not reflected in heap summary 253436 vex amd64->IR: unhandled instruction bytes: 0xF2 0xA6 (repne cmps) 258140 Valgrind on OS X always reports some memory "still reachable" +390754 unhandled amd64-darwin syscall: unix:216 (open_dprotected_np) 406674 False positive when reading bitfield value on code compiled with clang 7.0 413369 unhandled amd64-darwin syscall: unix:151 (getpgid) diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index f80b007fae..dc21bebeb1 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -274,7 +274,7 @@ DECL_TEMPLATE(darwin, __sysctl); // 202 // 213 Reserved for AppleTalk // NYI kqueue_from_portset_np 214 // NYI kqueue_portset_np 215 -// NYI mkcomplex 216 +DECL_TEMPLATE(darwin, open_dprotected_np) // 216 // NYI statv 217 // NYI lstatv 218 // NYI fstatv 219 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 1a474bb94f..668f2ef029 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -3626,6 +3626,43 @@ static void set1attr(ThreadId tid, void *attrData, SizeT attrDataSize) PRE_MEM_READ("setattrlist(attrBuf value)", (Addr)attrData, attrDataSize); } +// __NR_open_dprotected_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(216) +// int open_dprotected_np(const char *path, int flags, int dpclass, +// int dpflags, int mode); +PRE(open_dprotected_np) +{ + if (ARG2 & VKI_O_CREAT) { + // versiion that uses mode + PRINT("open_dprotected_np(path:%#lx(%s), flags:%#lx, " + "dpclass:%#lx, dpflags:%#lx, mode:%#lx)", + ARG1, (HChar*)ARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "open_dprotected_np", const char*, path, + int, flags, int, dpclass, int, dpflags, + int, mode); + } else { + // version that does not use mode + PRINT("open_dprotected_np(path:%#lx(%s), flags:%#lx, " + "dpclass:%#lx, dpflags:%#lx)", + ARG1, (HChar*)ARG1, ARG2, ARG3, ARG4); + PRE_REG_READ4(int, "open_dprotected_np", const char*, path, + int, flags, int, dpclass, int, dpflags); + } + PRE_MEM_RASCIIZ("open_dprotected_np(path)", ARG1); +} + +POST(open_dprotected_np) +{ + vg_assert(SUCCESS); + POST_newFd_RES; + if (!ML_(fd_allowed)(RES, "open_dprotected_np", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) + ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)(Addr)ARG1); + } +} + PRE(getattrlist) { PRINT("getattrlist(%#lx(%s), %#lx, %#lx, %lu, %lu)", @@ -10445,12 +10482,45 @@ POST(csrctl) } } +// __NR_guarded_open_dprotected_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(484) +// int guarded_open_dprotected_np(const char *path, const void *guard, +// u_int guardflags, int flags, int dpclass, +// int dpflags, int mode); PRE(guarded_open_dprotected_np) { - PRINT("guarded_open_dprotected_np(" - "path:%#lx(%s), guard:%#lx, guardflags:%#lx, flags:%#lx, " - "dpclass:%#lx, dpflags: %#lx) FIXME", - ARG1, (HChar*)ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + if (ARG4 & VKI_O_CREAT) { + // versiion that uses mode + PRINT("guarded_open_dprotected_np(" + "path:%#lx(%s), guard:%#lx, guardflags:%#lx, flags:%#lx, " + "dpclass:%#lx, dpflags:%#lx, mode:%#lx)", + ARG1, (HChar*)ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7); + PRE_REG_READ7(int, "guarded_open_dprotected_np", const char*, path, + const void*, guard, u_int, guardflags, int, flags, + int, dpclass, int, dpflags, int, mode); + } else { + // version that does not use mode + PRINT("guarded_open_dprotected_np(" + "path:%#lx(%s), guard:%#lx, guardflags:%#lx, flags:%#lx, " + "dpclass:%#lx, dpflags:%#lx)", + ARG1, (HChar*)ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(int, "guarded_open_dprotected_np", const char*, path, + const void*, guard, u_int, guardflags, int, flags, + int, dpclass, int, dpflags); + } + PRE_MEM_RASCIIZ("guarded_open_dprotected_np(path)", ARG1); +} + +POST(guarded_open_dprotected_np) +{ + vg_assert(SUCCESS); + POST_newFd_RES; + if (!ML_(fd_allowed)(RES, "guarded_open_dprotected_np", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) + ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)(Addr)ARG1); + } } PRE(guarded_write_np) @@ -11524,7 +11594,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_kqueue_from_portset_np), // _____(__NR_kqueue_portset_np), #endif -// _____(__NR_mkcomplex), + MACXY(__NR_open_dprotected_np, open_dprotected_np), // 216 // _____(__NR_statv), // _____(__NR_lstatv), // _____(__NR_fstatv), @@ -11830,7 +11900,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACX_(__NR_mkdirat, mkdirat), // 475 MACX_(__NR_bsdthread_ctl, bsdthread_ctl), // 478 MACXY(__NR_csrctl, csrctl), // 483 - MACX_(__NR_guarded_open_dprotected_np, guarded_open_dprotected_np), // 484 + MACXY(__NR_guarded_open_dprotected_np, guarded_open_dprotected_np), // 484 MACX_(__NR_guarded_write_np, guarded_write_np), // 485 MACX_(__NR_guarded_pwrite_np, guarded_pwrite_np), // 486 MACX_(__NR_guarded_writev_np, guarded_writev_np), // 487 diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index d6cfe56e60..904bf21238 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -475,7 +475,7 @@ #define __NR_kqueue_from_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(214) #define __NR_kqueue_portset_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(215) #endif -#define __NR_mkcomplex VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(216) +#define __NR_open_dprotected_np VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(216) #define __NR_statv VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(217) #define __NR_lstatv VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(218) #define __NR_fstatv VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(219) |