From f0378fa54b56755cf982eb517a009fb3dcf89ae5 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 1 Mar 2024 03:20:59 +0100 Subject: 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. --- libbpf/bpf_impl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libbpf') 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) { -- cgit v1.2.3