Source-Changes-HG archive

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

[src/trunk]: src/sys/lib/libkern Add garbage instructions at end of kern_asse...



details:   https://anonhg.NetBSD.org/src/rev/063fe124e7ac
branches:  trunk
changeset: 352080:063fe124e7ac
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Mar 14 09:22:37 2017 +0000

description:
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.

diffstat:

 sys/lib/libkern/kern_assert.c |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r 5d26c4a95f7d -r 063fe124e7ac sys/lib/libkern/kern_assert.c
--- a/sys/lib/libkern/kern_assert.c     Tue Mar 14 09:04:16 2017 +0000
+++ b/sys/lib/libkern/kern_assert.c     Tue Mar 14 09:22:37 2017 +0000
@@ -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 @@
        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");
 }



Home | Main Index | Thread Index | Old Index