From b2f70da50f8934fea199150c35c1763e03f72d6d Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 8 Nov 2024 20:35:21 +0100 Subject: Fix some C warnings, more makefile vars, etc. * add some more env vars to makefile * remove fpermissive from GCC builds * update Monoucha * fix borked seccomp filter length safety check (ugh) --- lib/chaseccomp/Makefile | 5 ++--- lib/chaseccomp/chaseccomp.c | 15 ++++++++++----- lib/monoucha | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/chaseccomp/Makefile b/lib/chaseccomp/Makefile index 9b17b38c..51934ace 100644 --- a/lib/chaseccomp/Makefile +++ b/lib/chaseccomp/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -Wall +CFLAGS += -Wall -Wextra all: chaseccomp.o @@ -14,8 +14,7 @@ chasc_defs_%: chasc_defs_%.c chasc_%.h: %.chasc.expanded gen_syscalls ./gen_syscalls $< >$@ -chaseccomp.o: chaseccomp.c chaseccomp.h chasc_network.h chasc_buffer.h - $(CC) $(CFLAGS) chaseccomp.c -c -o $@ +chaseccomp.o: chaseccomp.h chasc_network.h chasc_buffer.h clean: rm -f *.d *.o diff --git a/lib/chaseccomp/chaseccomp.c b/lib/chaseccomp/chaseccomp.c index 949d9ee8..20fc4861 100644 --- a/lib/chaseccomp/chaseccomp.c +++ b/lib/chaseccomp/chaseccomp.c @@ -19,11 +19,14 @@ #include #include #include +#include #include "chaseccomp.h" static void sigsys_handler_buffer(int sig, siginfo_t *info, void *ucontext) { + (void)sig; + (void)ucontext; fprintf(stderr, "Sandbox violation in buffer: syscall #%d\n", info->si_syscall); abort(); @@ -35,9 +38,7 @@ int cha_enter_buffer_sandbox(void) #include "chasc_buffer.h" }; #ifndef EXPECTED_COUNT -#error "network sandbox not built" -#elsif EXPECTED_COUNT != COUNTOF(filter) -#error "wrong network sandbox length" +#error "buffer sandbox not built" #endif struct sock_fprog prog = { .len = COUNTOF(filter), .filter = filter }; struct sigaction act = { @@ -45,6 +46,8 @@ int cha_enter_buffer_sandbox(void) .sa_sigaction = sigsys_handler_buffer, }; + static_assert(EXPECTED_COUNT == COUNTOF(filter), + "wrong buffer filter count"); if (sigaction(SIGSYS, &act, NULL) < 0) return 0; if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) @@ -56,6 +59,8 @@ int cha_enter_buffer_sandbox(void) static void sigsys_handler_network(int sig, siginfo_t *info, void *ucontext) { + (void)sig; + (void)ucontext; fprintf(stderr, "Sandbox violation in network: syscall #%d\n", info->si_syscall); abort(); @@ -69,8 +74,6 @@ int cha_enter_network_sandbox(void) }; #ifndef EXPECTED_COUNT #error "network sandbox not built" -#elsif EXPECTED_COUNT != COUNTOF(filter) -#error "wrong network sandbox length" #endif struct sock_fprog prog = { .len = COUNTOF(filter), .filter = filter }; struct sigaction act = { @@ -78,6 +81,8 @@ int cha_enter_network_sandbox(void) .sa_sigaction = sigsys_handler_network, }; + static_assert(EXPECTED_COUNT == COUNTOF(filter), + "wrong network filter count"); if (sigaction(SIGSYS, &act, NULL) < 0) return 0; if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) diff --git a/lib/monoucha b/lib/monoucha index 108d7319..33eb016a 160000 --- a/lib/monoucha +++ b/lib/monoucha @@ -1 +1 @@ -Subproject commit 108d7319ebab9af2c29eb429718d5237dca01a01 +Subproject commit 33eb016ad907131690b2c3ad73f83aebd996ba9d -- cgit