Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/nvmm Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/28bab7916758
branches:  netbsd-9
changeset: 963817:28bab7916758
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Apr 27 14:56:22 2020 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #857):

        sys/dev/nvmm/nvmm.c: revision 1.26

In nvmm_open(), make sure an implementation was found. This fixes an
initialization bug triggerable in certain conditions.

If you build nvmm inside the kernel, AND have a cpu that is not supported,
AND run nvmmctl (or qemu-nvmm, both being the only binaries in the "nvmm"
group), you get a page fault.

This is because when nvmm is built inside the kernel, the kernel registers
nvmm_cdevsw behind nvmm's back. The ioctl is therefore always accessible,
and will hit NULL pointers if nvmm_init() failed.

Problem reported by Andrei M. on netbsd-users@, thanks.

diffstat:

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

diffs (27 lines):

diff -r 4f381e6af873 -r 28bab7916758 sys/dev/nvmm/nvmm.c
--- a/sys/dev/nvmm/nvmm.c       Mon Apr 27 14:52:47 2020 +0000
+++ b/sys/dev/nvmm/nvmm.c       Mon Apr 27 14:56:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm.c,v 1.22.2.1 2019/11/10 12:58:30 martin Exp $     */
+/*     $NetBSD: nvmm.c,v 1.22.2.2 2020/04/27 14:56:22 martin Exp $     */
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.1 2019/11/10 12:58:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.2 2020/04/27 14:56:22 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1040,6 +1040,8 @@
        struct file *fp;
        int error, fd;
 
+       if (__predict_false(nvmm_impl == NULL))
+               return ENXIO;
        if (minor(dev) != 0)
                return EXDEV;
        if (!(flags & O_CLOEXEC))



Home | Main Index | Thread Index | Old Index