diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2007-12-20 09:01:17 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2007-12-20 09:01:17 -0500 |
commit | 2c3b20e91fe3a083c5d9bc79437c485866ea251c (patch) | |
tree | 6d2b9e00efc89452863e71a8712398aeee3eccdd /kernel/panic.c | |
parent | 67e2be02328b9a61a9c799fbdd4ec94d7da0c323 (diff) |
debug: add end-of-oops marker
Right now it's nearly impossible for parsers that collect kernel crashes
from logs or emails (such as www.kerneloops.org) to detect the
end-of-oops condition. In addition, it's not currently possible to
detect whether or not 2 oopses that look alike are actually the same
oops reported twice, or are truly two unique oopses.
This patch adds an end-of-oops marker, and makes the end marker include
a very simple 64-bit random ID to be able to detect duplicate reports.
Normally, this ID is calculated as a late_initcall() (in the hope that
at that time there is enough entropy to get a unique enough ID); however
for early oopses the oops_exit() function needs to generate the ID on
the fly.
We do this all at the _end_ of an oops printout, so this does not impact
our ability to get the most important portions of a crash out to the
console first.
[ Sidenote: the already existing oopses-since-bootup counter we print
during crashes serves as the differentiator between multiple oopses
that trigger during the same bootup. ]
Tested on 32-bit and 64-bit x86. Artificially injected very early
crashes as well, as expected they result in this constant ID after
multiple bootups:
---[ end trace ca143223eefdc828 ]---
---[ end trace ca143223eefdc828 ]---
because the random pools are still all zero. But it all still works
fine and causes no additional problems (which is the main goal of
instrumentation code).
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/panic.c')
-rw-r--r-- | kernel/panic.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 6f6e03e91595..da4d6bac270e 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/nmi.h> | 19 | #include <linux/nmi.h> |
20 | #include <linux/kexec.h> | 20 | #include <linux/kexec.h> |
21 | #include <linux/debug_locks.h> | 21 | #include <linux/debug_locks.h> |
22 | #include <linux/random.h> | ||
22 | 23 | ||
23 | int panic_on_oops; | 24 | int panic_on_oops; |
24 | int tainted; | 25 | int tainted; |
@@ -266,12 +267,29 @@ void oops_enter(void) | |||
266 | } | 267 | } |
267 | 268 | ||
268 | /* | 269 | /* |
270 | * 64-bit random ID for oopses: | ||
271 | */ | ||
272 | static u64 oops_id; | ||
273 | |||
274 | static int init_oops_id(void) | ||
275 | { | ||
276 | if (!oops_id) | ||
277 | get_random_bytes(&oops_id, sizeof(oops_id)); | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | late_initcall(init_oops_id); | ||
282 | |||
283 | /* | ||
269 | * Called when the architecture exits its oops handler, after printing | 284 | * Called when the architecture exits its oops handler, after printing |
270 | * everything. | 285 | * everything. |
271 | */ | 286 | */ |
272 | void oops_exit(void) | 287 | void oops_exit(void) |
273 | { | 288 | { |
274 | do_oops_enter_exit(); | 289 | do_oops_enter_exit(); |
290 | init_oops_id(); | ||
291 | printk(KERN_WARNING "---[ end trace %016llx ]---\n", | ||
292 | (unsigned long long)oops_id); | ||
275 | } | 293 | } |
276 | 294 | ||
277 | #ifdef CONFIG_CC_STACKPROTECTOR | 295 | #ifdef CONFIG_CC_STACKPROTECTOR |