@@ -1319,6 +1319,32 @@ INTERCEPTOR(ssize_t, process_vm_writev, pid_t pid,
13191319#define RTSAN_MAYBE_INTERCEPT_PROCESS_VM_WRITEV
13201320#endif
13211321
1322+ #if SANITIZER_INTERCEPT_PRCTL
1323+ INTERCEPTOR (int , prctl, int operation, ...) {
1324+ __rtsan_notify_intercepted_call (" prctl" );
1325+
1326+ va_list args;
1327+ va_start (args, operation);
1328+
1329+ // in practice, prctl syscall accepts up to 4 additional arguments.
1330+ // With an operation like PR_SET_NAME however
1331+ // call does not have to set beyond the 2nd but
1332+ // it is good practice to set to NULL the rest.
1333+ using arg_type = unsigned long ;
1334+ arg_type arg1 = va_arg (args, arg_type);
1335+ arg_type arg2 = va_arg (args, arg_type);
1336+ arg_type arg3 = va_arg (args, arg_type);
1337+ arg_type arg4 = va_arg (args, arg_type);
1338+
1339+ va_end (args);
1340+
1341+ return REAL (prctl)(operation, arg1, arg2, arg3, arg4);
1342+ }
1343+ #define RTSAN_MAYBE_INTERCEPT_PRCTL INTERCEPT_FUNCTION (prctl)
1344+ #else
1345+ #define RTSAN_MAYBE_INTERCEPT_PRCTL
1346+ #endif
1347+
13221348// TODO: the `wait` family of functions is an oddity. In testing, if you
13231349// intercept them, Darwin seemingly ignores them, and linux never returns from
13241350// the test. Revisit this in the future, but hopefully intercepting fork/exec is
@@ -1520,6 +1546,7 @@ void __rtsan::InitializeInterceptors() {
15201546
15211547 RTSAN_MAYBE_INTERCEPT_PROCESS_VM_READV;
15221548 RTSAN_MAYBE_INTERCEPT_PROCESS_VM_WRITEV;
1549+ RTSAN_MAYBE_INTERCEPT_PRCTL;
15231550
15241551 INTERCEPT_FUNCTION (syscall);
15251552}
0 commit comments