Source-Changes-HG archive

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

[src/trunk]: src/sys/kern kern: Add debug.crashme.null_jump.



details:   https://anonhg.NetBSD.org/src/rev/25baabce3959
branches:  trunk
changeset: 1026512:25baabce3959
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Nov 27 14:11:14 2021 +0000

description:
kern: Add debug.crashme.null_jump.

diffstat:

 sys/kern/kern_crashme.c |  14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r c099e02d905c -r 25baabce3959 sys/kern/kern_crashme.c
--- a/sys/kern/kern_crashme.c   Sat Nov 27 14:11:04 2021 +0000
+++ b/sys/kern/kern_crashme.c   Sat Nov 27 14:11:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_crashme.c,v 1.4 2021/09/07 11:00:13 riastradh Exp $       */
+/*     $NetBSD: kern_crashme.c,v 1.5 2021/11/27 14:11:14 riastradh Exp $       */
 
 /*
  * Copyright (c) 2018, 2019 Matthew R. Green
@@ -59,6 +59,7 @@
 
 static int crashme_panic(int);
 static int crashme_null_deref(int);
+static int crashme_null_jump(int);
 #ifdef DDB
 static int crashme_ddb(int);
 #endif
@@ -73,6 +74,7 @@
 static crashme_node nodes[] = {
     CMNODE("panic", "plain old panic", crashme_panic),
     CMNODE("null_deref", "null dereference", crashme_null_deref),
+    CMNODE("null_jump", "jump to null", crashme_null_jump),
 #ifdef DDB
     CMNODE("ddb", "enter ddb directly", crashme_ddb),
 #endif
@@ -249,6 +251,16 @@
        return -1;
 }
 
+static int
+crashme_null_jump(int flags)
+{
+       void (*volatile f)(int) = NULL;
+
+       (*f)(flags);
+       /* make sure to have a nontrivial return address here */
+       return -1;
+}
+
 #ifdef DDB
 static int
 crashme_ddb(int flags)



Home | Main Index | Thread Index | Old Index