Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/amd64 Add missing address check. This broke t...



details:   https://anonhg.NetBSD.org/src/rev/edcdea9bbb5e
branches:  trunk
changeset: 451944:edcdea9bbb5e
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jun 12 14:28:38 2019 +0000

description:
Add missing address check. This broke things like:

        crash -w
        w /l ipsec_debug 1

with an invalid address, because it found the first readonly segment and
returned EFAULT. I guess this never worked properly, but this got exposed
when maxv made text and rodata actually R/O?

diffstat:

 sys/arch/amd64/amd64/machdep.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 711c8dc709e7 -r edcdea9bbb5e sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Jun 12 13:53:25 2019 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Jun 12 14:28:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.331 2019/05/19 08:46:15 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.332 2019/06/12 14:28:38 christos Exp $   */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.331 2019/05/19 08:46:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.332 2019/06/12 14:28:38 christos Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -2161,6 +2161,8 @@
        for (i = 0; i < BTSPACE_NSEGS; i++) {
                kva = bootspace.segs[i].va;
                kva_end = kva + bootspace.segs[i].sz;
+               if (v < kva || v >= kva_end)
+                       continue;
                *handled = true;
                if (bootspace.segs[i].type == BTSEG_TEXT ||
                    bootspace.segs[i].type == BTSEG_RODATA) {
@@ -2180,8 +2182,9 @@
 
        if (v >= bootspace.smodule && v < bootspace.emodule) {
                *handled = true;
-               if (!uvm_map_checkprot(module_map, v, v + 1, prot))
+               if (!uvm_map_checkprot(module_map, v, v + 1, prot)) {
                        return EFAULT;
+               }
        } else {
                *handled = false;
        }



Home | Main Index | Thread Index | Old Index