Module Name:    src
Committed By:   riastradh
Date:           Sat Nov 27 14:11:14 UTC 2021

Modified Files:
        src/sys/kern: kern_crashme.c

Log Message:
kern: Add debug.crashme.null_jump.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/kern/kern_crashme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_crashme.c
diff -u src/sys/kern/kern_crashme.c:1.4 src/sys/kern/kern_crashme.c:1.5
--- src/sys/kern/kern_crashme.c:1.4	Tue Sep  7 11:00:13 2021
+++ src/sys/kern/kern_crashme.c	Sat Nov 27 14:11:14 2021
@@ -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_sysctl_forwarder(SYSC
 
 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 int crashme_ddb(int);
 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 @@ crashme_null_deref(int flags)
 	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)

Reply via email to