Source-Changes-HG archive

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

[src/netbsd-7-0]: src/sys/dev Apply patch (requested by chs in ticket #1429):



details:   https://anonhg.NetBSD.org/src/rev/583310052e26
branches:  netbsd-7-0
changeset: 801331:583310052e26
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Jul 08 16:12:44 2017 +0000

description:
Apply patch (requested by chs in ticket #1429):
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 afacc8a9abe6 -r 583310052e26 sys/dev/cgd.c
--- a/sys/dev/cgd.c     Wed Jun 21 17:09:53 2017 +0000
+++ b/sys/dev/cgd.c     Sat Jul 08 16:12:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.90.4.1 2015/11/04 16:24:38 riz Exp $ */
+/* $NetBSD: cgd.c,v 1.90.4.2 2017/07/08 16:12:44 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.90.4.1 2015/11/04 16:24:38 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.90.4.2 2017/07/08 16:12:44 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -586,12 +586,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