Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/9969a2069245
branches:  netbsd-9
changeset: 984101:9969a2069245
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Jun 21 17:32:52 2021 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1307):

        sys/arch/amd64/amd64/db_disasm.c: revision 1.28
        sys/arch/i386/i386/db_disasm.c: revision 1.49

ddb/amd64: Don't go out of the way to detect invalid addresses.

db_disasm had logic to detect invalid addresses before trying to
disassemble them.  But when disassembling a null instruction address,
the logic to detect invalid addresses itself tried to dereference an
invalid address.

db_get_value can already handle this situation gracefully, so there is
no need for this faulty fault-avoidance logic.

Fixes double-fault in ddb on calling null function pointers.  With
any luck, this should make diagnosing such bugs easier in the future!

ddb/i386: Don't go out of the way to detect invalid addresses.
db_read_bytes already does this better (but didn't at the time this
check was originally added back in 1998).  Not sure if this code had
the same mistake as the amd64 code causing it to trip over its own
shoelaces, but there should be no need for it here.

diffstat:

 sys/arch/amd64/amd64/db_disasm.c |  29 ++---------------------------
 sys/arch/i386/i386/db_disasm.c   |  24 ++----------------------
 2 files changed, 4 insertions(+), 49 deletions(-)

diffs (97 lines):

diff -r 94a85796a355 -r 9969a2069245 sys/arch/amd64/amd64/db_disasm.c
--- a/sys/arch/amd64/amd64/db_disasm.c  Mon Jun 21 17:27:57 2021 +0000
+++ b/sys/arch/amd64/amd64/db_disasm.c  Mon Jun 21 17:32:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $      */
+/*     $NetBSD: db_disasm.c,v 1.27.4.1 2021/06/21 17:32:52 martin Exp $        */
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.27.4.1 2021/06/21 17:32:52 martin Exp $");
 
 #ifndef _KERNEL
 #include <sys/types.h>
@@ -1191,33 +1191,8 @@
        uint64_t imm64;
        int     len;
        struct i_addr   address;
-#ifdef _KERNEL
-       pt_entry_t *pte, *pde;
-#endif
        u_int   rex = 0;
 
-#ifdef _KERNEL
-       /*
-        * Don't try to disassemble the location if the mapping is invalid.
-        * If we do, we'll fault, and end up debugging the debugger!
-        * in the case of largepages, "pte" is really the pde and "pde" is
-        * really the entry for the pdp itself.
-        */
-       if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-               pte = kvtopte((vaddr_t)loc);
-       else
-               pte = vtopte((vaddr_t)loc);
-       if ((vaddr_t)pte >= VM_MIN_KERNEL_ADDRESS)
-               pde = kvtopte((vaddr_t)pte);
-       else
-               pde = vtopte((vaddr_t)pte);
-
-       if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-               db_printf("invalid address\n");
-               return (loc);
-       }
-#endif
-
        get_value_inc(inst, loc, 1, false);
        short_addr = false;
        size = LONG;
diff -r 94a85796a355 -r 9969a2069245 sys/arch/i386/i386/db_disasm.c
--- a/sys/arch/i386/i386/db_disasm.c    Mon Jun 21 17:27:57 2021 +0000
+++ b/sys/arch/i386/i386/db_disasm.c    Mon Jun 21 17:32:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $      */
+/*     $NetBSD: db_disasm.c,v 1.48.4.1 2021/06/21 17:32:52 martin Exp $        */
 
 /* 
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.48.4.1 2021/06/21 17:32:52 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -1132,26 +1132,6 @@
        int     len;
        struct i_addr   address;
 
-#ifdef _KERNEL
-       pt_entry_t *pte, *pde;
-
-       /*
-        * Don't try to disassemble the location if the mapping is invalid.
-        * If we do, we'll fault, and end up debugging the debugger!
-        * in the case of largepages, "pte" is really the pde and "pde" is
-        * really the entry for the pdp itself.
-        */
-       if ((vaddr_t)loc >= VM_MIN_KERNEL_ADDRESS)
-               pte = kvtopte((vaddr_t)loc);
-       else
-               pte = vtopte((vaddr_t)loc);
-       pde = vtopte((vaddr_t)pte);
-       if ((*pde & PTE_P) == 0 || (*pte & PTE_P) == 0) {
-               db_printf("invalid address\n");
-               return (loc);
-       }
-#endif
-
        get_value_inc(inst, loc, 1, false);
        short_addr = false;
        size = LONG;



Home | Main Index | Thread Index | Old Index