aboutsummaryrefslogtreecommitdiffstats
path: root/lib/chaseccomp
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-08 20:35:21 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-08 20:35:21 +0100
commitb2f70da50f8934fea199150c35c1763e03f72d6d (patch)
tree0dbbcc4777dbb58e3468a10d8abf83563bed04d9 /lib/chaseccomp
parent2ee9bc323c14de75c147c1d2051bdbf0cd6e28cf (diff)
downloadchawan-b2f70da50f8934fea199150c35c1763e03f72d6d.tar.gz
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)
Diffstat (limited to 'lib/chaseccomp')
-rw-r--r--lib/chaseccomp/Makefile5
-rw-r--r--lib/chaseccomp/chaseccomp.c15
2 files changed, 12 insertions, 8 deletions
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 <fcntl.h>
#include <stdint.h>
#include <signal.h>
+#include <assert.h>
#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))