Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net/npf Fix locking issue: npf_default_pass needs to be ...



details:   https://anonhg.NetBSD.org/src/rev/8a9e2ee20ddc
branches:  trunk
changeset: 980165:8a9e2ee20ddc
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 25 17:17:19 2021 +0000

description:
Fix locking issue: npf_default_pass needs to be called with the config lock
held.

diffstat:

 sys/net/npf/npf_os.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r dcb4c8b399f3 -r 8a9e2ee20ddc sys/net/npf/npf_os.c
--- a/sys/net/npf/npf_os.c      Mon Jan 25 16:21:41 2021 +0000
+++ b/sys/net/npf/npf_os.c      Mon Jan 25 17:17:19 2021 +0000
@@ -33,7 +33,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.19 2020/08/18 07:53:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.20 2021/01/25 17:17:19 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pf.h"
@@ -321,8 +321,16 @@
 bool
 npf_autounload_p(void)
 {
+       if (npf_active_p())
+               return false;
+
        npf_t *npf = npf_getkernctx();
-       return !npf_active_p() && npf_default_pass(npf);
+
+       npf_config_enter(npf);
+       bool pass = npf_default_pass(npf);
+       npf_config_exit(npf);
+
+       return pass;
 }
 
 /*



Home | Main Index | Thread Index | Old Index