Module Name:    src
Committed By:   rin
Date:           Wed Sep 18 23:20:20 UTC 2024

Modified Files:
        src/sys/net: if_tun.c

Log Message:
tun(4): Mark tunread_filtops `FILTEROP_MPSAFE`

Filter handlers have already been MP-safe since 2018:
https://mail-index.netbsd.org/source-changes/2018/08/06/msg097317.html

Note that we do not expect deadlocks similar to bpf(4) (PR kern/58531),
b/w KERNEL_LOCK and spin mutex for TX queue.

For tun(4), filt_tunread() acquires adaptive mutex. This is forbidden
when spin mutex is already held.

Such a path must have already been detected if present.

Thanks ozaki-r@ for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/net/if_tun.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_tun.c
diff -u src/sys/net/if_tun.c:1.176 src/sys/net/if_tun.c:1.177
--- src/sys/net/if_tun.c:1.176	Fri Jul  5 04:31:53 2024
+++ src/sys/net/if_tun.c	Wed Sep 18 23:20:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tun.c,v 1.176 2024/07/05 04:31:53 rin Exp $	*/
+/*	$NetBSD: if_tun.c,v 1.177 2024/09/18 23:20:20 rin Exp $	*/
 
 /*
  * Copyright (c) 1988, Julian Onions <j...@cs.nott.ac.uk>
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.176 2024/07/05 04:31:53 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.177 2024/09/18 23:20:20 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1097,7 +1097,7 @@ filt_tunread(struct knote *kn, long hint
 }
 
 static const struct filterops tunread_filtops = {
-	.f_flags = FILTEROP_ISFD,
+	.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
 	.f_attach = NULL,
 	.f_detach = filt_tunrdetach,
 	.f_event = filt_tunread,

Reply via email to