execve is denied and the supervisor hangs when threads are parked in notifications
Since d37b8c0, sandlock learn hangs on Claude Code read and write workloads.
Asking Claude Code to read a single file under learn is enough. The supervisor prints a run of "abandoning its ptrace attachment", denies the subprocesses the tool spawns, and then never exits, so learn never writes a profile and the command has to be killed.
Any workload that calls execve while its other threads are making intercepted syscalls hits this.
Reproduction
// gcc -O2 -pthread -o repro repro.c
#define _GNU_SOURCE
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
static volatile int stop;
// Keep tasks parked in a syscall the supervisor intercepts.
static void *hammer(void *arg) {
(void)arg;
while (!stop) {
int fd = open("/etc/hostname", O_RDONLY);
if (fd >= 0) close(fd);
}
return NULL;
}
int main(void) {
pthread_t t[8];
for (int i = 0; i < 8; i++) pthread_create(&t[i], NULL, hammer, NULL);
for (int i = 0; i < 20; i++) {
pid_t p = fork();
if (p == 0) { execl("/bin/true", "true", (char *)NULL); _exit(127); }
int st;
if (waitpid(p, &st, 0) < 0) { perror("waitpid"); return 1; }
if (!WIFEXITED(st) || WEXITSTATUS(st) != 0) {
fprintf(stderr, "FAIL: exec %d exited %d\n", i, WEXITSTATUS(st));
return 1;
}
printf("exec %d ok\n", i);
fflush(stdout);
}
stop = 1;
for (int i = 0; i < 8; i++) pthread_join(t[i], NULL);
puts("ALL EXECS OK");
return 0;
}
sandlock learn -o /tmp/p.toml -- ./repro
Observed
exec 0 ok
sandlock: tid 14718 never left its kernel wait; abandoning its ptrace attachment
... 8 of these ...
sandlock: argv-safety freeze failed for pid 14733: Operation not permitted (os error 1); denying execve to preserve TOCTOU invariant
FAIL: exec 1 exited 127
Scope
The freeze engages when argv_safety_required is set, which is policy_events.contains(Process) || exec_handler (resolved.rs:96). That covers sandlock learn and any library caller whose policy_fn receives Process events, which is the default. Plain sandlock run installs no policy_fn, so it does not engage the freeze and the repro passes there.