Skip to content

Commit

Permalink
Allow nonmatching syscalls to continue normally
Browse files Browse the repository at this point in the history
This part of the code should never be reached if the kernel is
functioning correctly, but it is better to handle this scenario anyway.
  • Loading branch information
vimpostor committed Jan 17, 2024
1 parent 49e426b commit 5a1c19f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/bin/seccomp/seccomp_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ int handle_req(struct seccomp_notif *req,
resp->id = req->id;
resp->error = -EPERM;
resp->val = 0;
resp->flags = 0;

#ifndef NDEBUG
bool found = false;
Expand All @@ -143,9 +144,12 @@ int handle_req(struct seccomp_notif *req,
}
if (!found) {
fprintf(stderr, "huh? trapped system call %d that does not appear on our list?\n", req->data.nr);
if (0) {
// TODO: Continue the syscall normally if nothing matches
resp->flags |= SECCOMP_USER_NOTIF_FLAG_CONTINUE;
// allow target to continue the syscall normally
resp->flags |= SECCOMP_USER_NOTIF_FLAG_CONTINUE;
resp->error = 0;
resp->val = 0;
if (ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, resp) < 0 && errno != ENOENT) {
perror("ioctl send");
}
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo "c" > /tmp/c
gcc tests/tests_general.c -o tests_general
COPYCAT="/tmp/a /tmp/b" build/copycat -- ./tests_general

gcc -lm tests/benchmark.c -o benchmark
gcc tests/benchmark.c -lm -o benchmark
echo -e "\nRunning benchmark without interception:"
./benchmark
echo -e "\nRunning benchmark with interception:"
Expand Down

0 comments on commit 5a1c19f

Please sign in to comment.