Module Name: src
Committed By: riastradh
Date: Tue Mar 14 09:22:38 UTC 2017
Modified Files:
src/sys/lib/libkern: kern_assert.c
Log Message:
Add garbage instructions at end of kern_assert after vpanic.
This avoids having the return address passed to vpanic confusingly
appear to be some other symbol.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libkern/kern_assert.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/lib/libkern/kern_assert.c
diff -u src/sys/lib/libkern/kern_assert.c:1.3 src/sys/lib/libkern/kern_assert.c:1.4
--- src/sys/lib/libkern/kern_assert.c:1.3 Tue Nov 19 16:56:21 2013
+++ src/sys/lib/libkern/kern_assert.c Tue Mar 14 09:22:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_assert.c,v 1.3 2013/11/19 16:56:21 christos Exp $ */
+/* $NetBSD: kern_assert.c,v 1.4 2017/03/14 09:22:37 riastradh Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
@@ -50,4 +50,13 @@ kern_assert(const char *fmt, ...)
va_start(ap, fmt);
vpanic(fmt, ap);
va_end(ap);
+
+ /*
+ * Force instructions at the return address of vpanic before
+ * the next symbol, which otherwise the compiler may omit
+ * because vpanic is marked noreturn. This prevents seeing
+ * whatever random symbol came after kern_assert in the linked
+ * kernel in stack traces for assertion failures.
+ */
+ asm volatile(".long 0");
}