Source-Changes-HG archive

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

[src/netbsd-6-1]: src/sys/dev Apply patch (requested by chs in ticket #1455):



details:   https://anonhg.NetBSD.org/src/rev/ea8f553e8837
branches:  netbsd-6-1
changeset: 776214:ea8f553e8837
user:      snj <snj%NetBSD.org@localhost>
date:      Fri Jul 21 04:02:34 2017 +0000

description:
Apply patch (requested by chs in ticket #1455):
Avoid crashes by checking if a cgd device has been configured before
processing most ioctls, and failing with ENXIO if the device is not
configured.

diffstat:

 sys/dev/cgd.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r ad6cd34ce4aa -r ea8f553e8837 sys/dev/cgd.c
--- a/sys/dev/cgd.c     Fri Jul 14 06:24:37 2017 +0000
+++ b/sys/dev/cgd.c     Fri Jul 21 04:02:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.76 2011/11/13 23:03:24 christos Exp $ */
+/* $NetBSD: cgd.c,v 1.76.12.1 2017/07/21 04:02:34 snj Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.76 2011/11/13 23:03:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.76.12.1 2017/07/21 04:02:34 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -549,12 +549,16 @@
                 */
                if ((flag & FWRITE) == 0)
                        return (EBADF);
+               if ((dksc->sc_flags & DKF_INITED) == 0)
+                       return ENXIO;
 
                /*
                 * We pass this call down to the underlying disk.
                 */
                return VOP_IOCTL(cs->sc_tvn, cmd, data, flag, l->l_cred);
        default:
+               if ((dksc->sc_flags & DKF_INITED) == 0)
+                       return ENXIO;
                return dk_ioctl(di, dksc, dev, cmd, data, flag, l);
        }
 }



Home | Main Index | Thread Index | Old Index