summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2024-03-01 03:20:59 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-03-01 03:20:59 +0100
commitf0378fa54b56755cf982eb517a009fb3dcf89ae5 (patch)
treedb1445d8c637edb029366ced465a5466112fe838
parent1afe753f75f1e64254c8e29c4c2030e25fa95392 (diff)
libbpf: avoid aborting on unknown instruction
Userland might load BPF programs with unknown instructions, we currently don't pre-check against that. In such a case, we shouldn't make netdde completely abort, and rather just return 0 like e.g. in the division by zero case.
-rw-r--r--libbpf/bpf_impl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libbpf/bpf_impl.c b/libbpf/bpf_impl.c
index acd53409..c78176c2 100644
--- a/libbpf/bpf_impl.c
+++ b/libbpf/bpf_impl.c
@@ -85,7 +85,8 @@ bpf_do_filter(net_rcv_port_t infp, char *p, unsigned int wirelen,
switch (pc->code) {
default:
- abort();
+ // Unknown instruction, abort
+ return 0;
case BPF_RET|BPF_K:
if (infp->rcv_port == MACH_PORT_NULL &&
*entpp == 0) {