Module Name:    src
Committed By:   knakahara
Date:           Thu Jan 24 09:31:10 UTC 2019

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

Log Message:
Add KERNEL_LOCK in ppptioctl() to protect struct ppp_softc members.

struct linesw.i_ioctl can be called without any preservation when the caller's
struct cdevsw is set D_MPSAFE such as ucom(4).


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/net/ppp_tty.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/ppp_tty.c
diff -u src/sys/net/ppp_tty.c:1.64 src/sys/net/ppp_tty.c:1.65
--- src/sys/net/ppp_tty.c:1.64	Wed Feb  7 06:19:43 2018
+++ src/sys/net/ppp_tty.c	Thu Jan 24 09:31:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ppp_tty.c,v 1.64 2018/02/07 06:19:43 mrg Exp $	*/
+/*	$NetBSD: ppp_tty.c,v 1.65 2019/01/24 09:31:09 knakahara Exp $	*/
 /*	Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp 	*/
 
 /*
@@ -93,7 +93,7 @@
 /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.64 2018/02/07 06:19:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.65 2019/01/24 09:31:09 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "ppp.h"
@@ -439,8 +439,15 @@ ppptioctl(struct tty *tp, u_long cmd, vo
     struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc;
     int error, s;
 
-    if (sc == NULL || tp != (struct tty *) sc->sc_devp)
-	return (EPASSTHROUGH);
+    if (sc == NULL)
+        return (EPASSTHROUGH);
+
+    KERNEL_LOCK(1, NULL);
+
+    if (tp != (struct tty *) sc->sc_devp) {
+        error = EPASSTHROUGH;
+        goto out;
+    }
 
     error = 0;
     switch (cmd) {
@@ -492,6 +499,8 @@ ppptioctl(struct tty *tp, u_long cmd, vo
 	    pppgetm(sc);
     }
 
+ out:
+    KERNEL_UNLOCK_ONE(NULL);
     return error;
 }
 

Reply via email to