From 8d44fb83386c1834163f037b077c03cf6cc7f748 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Mon, 16 Jan 2023 17:22:51 +0100 Subject: Use signals instead of connect for synchronization The connect syscall was used to synchronize seitan and the eater for the seccomp installation filter and notifier initialization. However, we assume that the fd 0 is always free, and this might not always be the case. Try to implement an alternative and more robust solution. Signed-off-by: Alice Frosi --- eater.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'eater.c') diff --git a/eater.c b/eater.c index cd03b44..ad2136e 100644 --- a/eater.c +++ b/eater.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,8 @@ static int seccomp(unsigned int operation, unsigned int flags, void *args) return syscall(__NR_seccomp, operation, flags, args); } +static void signal_handler(__attribute__((unused))int s){} + /** * main() - Entry point * @argc: Argument count @@ -87,6 +90,7 @@ int main(int argc, char **argv) struct sock_filter filter[1024]; struct arguments arguments; struct sock_fprog prog; + struct sigaction act; size_t n; int fd; @@ -106,8 +110,10 @@ int main(int argc, char **argv) perror("seccomp"); exit(EXIT_FAILURE); } + act.sa_handler = signal_handler; + sigaction(SIGCONT, &act, NULL); + pause(); - connect(0, NULL, 0); /* Wait for seitan to unblock this */ execvpe(argv[arguments.program_index], &argv[arguments.program_index], environ); if (errno != ENOENT) { -- cgit v1.2.3