Source-Changes-HG archive

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

[src/trunk]: src/sys/net Add KERNEL_LOCK in ppptioctl() to protect struct ppp...



details:   https://anonhg.NetBSD.org/src/rev/38e5918ff742
branches:  trunk
changeset: 838610:38e5918ff742
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu Jan 24 09:31:09 2019 +0000

description:
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).

diffstat:

 sys/net/ppp_tty.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 0846d34b45d7 -r 38e5918ff742 sys/net/ppp_tty.c
--- a/sys/net/ppp_tty.c Thu Jan 24 08:56:43 2019 +0000
+++ b/sys/net/ppp_tty.c Thu Jan 24 09:31:09 2019 +0000
@@ -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 @@
     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 @@
            pppgetm(sc);
     }
 
+ out:
+    KERNEL_UNLOCK_ONE(NULL);
     return error;
 }
 



Home | Main Index | Thread Index | Old Index