Source-Changes-HG archive

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

[src/trunk]: src/sys/net tun(4): Reduce lock from IPL_NET to IPL_SOFTNET.



details:   https://anonhg.NetBSD.org/src/rev/f3110bc60964
branches:  trunk
changeset: 363499:f3110bc60964
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Mar 13 21:32:27 2022 +0000

description:
tun(4): Reduce lock from IPL_NET to IPL_SOFTNET.

This is never taken from hardware interrupt handlers any more, as far
as I can tell -- only SOFTINT_NET soft interrupt handlers.

This avoids trying to take an adaptive lock, proc_lock, in fownsignal
while holding a spin lock.  Unfortunately, it doesn't entirely fix the
problem -- proc_lock is at IPL_NONE, and is held across some not
entirely trivial computations like allocating a new pid table.  So it
would really be better if we had some way to deliver SIGIO without
taking proc_lock.

Reported-by: syzbot+3dd54993d3e92e697e72%syzkaller.appspotmail.com@localhost
Reported-by: syzbot+aca29415f2f0bf23f082%syzkaller.appspotmail.com@localhost

diffstat:

 sys/net/if_tun.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 4b075baef940 -r f3110bc60964 sys/net/if_tun.c
--- a/sys/net/if_tun.c  Sun Mar 13 21:32:15 2022 +0000
+++ b/sys/net/if_tun.c  Sun Mar 13 21:32:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.167 2022/03/13 21:32:15 riastradh Exp $   */
+/*     $NetBSD: if_tun.c,v 1.168 2022/03/13 21:32:27 riastradh Exp $   */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.167 2022/03/13 21:32:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.168 2022/03/13 21:32:27 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -216,7 +216,7 @@
 {
 
        tp->tun_unit = unit;
-       mutex_init(&tp->tun_lock, MUTEX_DEFAULT, IPL_NET);
+       mutex_init(&tp->tun_lock, MUTEX_DEFAULT, IPL_SOFTNET);
        cv_init(&tp->tun_cv, "tunread");
        selinit(&tp->tun_rsel);
        selinit(&tp->tun_wsel);



Home | Main Index | Thread Index | Old Index