-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When running under seccomp, sometimes sysexit handlers fail to execute. This is possible when the first syscall a process makes, before seccomp is enabled, gets handled in the SIGTRAP path. However the conditions for this to occur seem fairly random, so we fork out many processes to make it likely that at least some hit this problem. This problem may be related to issue #106.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*- */ | ||
#include <stdlib.h> | ||
#include <sys/utsname.h> | ||
#include <sys/wait.h> /* wait(2), */ | ||
#include <unistd.h> | ||
#include <string.h> | ||
|
||
/* Related to github issue #106. | ||
* Test if sysexit handlers execute, using uname handling | ||
* in the kompat extension. The test case is meant to be | ||
* run with "-k 3.4242XX" cmdline argument. | ||
* The bug could occur during the first traced syscall, | ||
* before seccomp got enabled. | ||
* However there was some kind of a random factor there, | ||
* so we fork out many processes to make it likely that at least | ||
* some would hit this problem. */ | ||
|
||
int main() | ||
{ | ||
int status; | ||
struct utsname s; | ||
for (int i = 0; i < 5; i++) { | ||
fork(); | ||
} | ||
uname(&s); | ||
int child_status; | ||
while ((status = wait(&child_status)) >= 0) { | ||
if (!WIFEXITED(child_status) || (WEXITSTATUS(child_status) == EXIT_FAILURE)) | ||
exit(EXIT_FAILURE); | ||
} | ||
if (strcmp("3.4242XX", s.release) == 0) { | ||
exit(EXIT_SUCCESS); | ||
} | ||
exit(EXIT_FAILURE); | ||
} |