From: visa Date: Thu, 13 Jan 2022 14:12:02 +0000 (+0000) Subject: Return an error if bpfilter_lookup() fails in bpfkqfilter() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1c4e6f78fdf9ed3e8694a73add4957d65d1dd27b;p=openbsd Return an error if bpfilter_lookup() fails in bpfkqfilter() The lookup should not fail because the kernel lock should prevent simultaneous detaching on the vnode layer. However, most other device kqfilter routines check the lookup's outcome anyway, which is maybe a bit more forgiving. OK mpi@ --- diff --git a/sys/net/bpf.c b/sys/net/bpf.c index b5c939da778..64a1936d8f8 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.207 2021/11/10 04:45:15 dlg Exp $ */ +/* $OpenBSD: bpf.c,v 1.208 2022/01/13 14:12:02 visa Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1177,6 +1177,8 @@ bpfkqfilter(dev_t dev, struct knote *kn) KERNEL_ASSERT_LOCKED(); d = bpfilter_lookup(minor(dev)); + if (d == NULL) + return (ENXIO); switch (kn->kn_filter) { case EVFILT_READ: