Skip to contentSkip to conversation

stacktrace: don't crash on invalid stack trace structs

PATCH Applied Johannes Berg 2 participants 2 messages May 4, 2008 – May 5, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stacktrace: don't crash on invalid stack trace structs

This patch makes the stacktrace printout code warn when the entries pointer is unset rather than crashing when trying to access it in an attempt to make it a bit more robust.

---
I was saving a stacktrace into an skb and forgot to copy it across skb copies... Not sure if you want this, I have since fixed the code, but it would have been easier had the kernel not crashed in an interrupt.

kernel/stacktrace.c +3 -0
@@ -13,6 +13,9 @@ void print_stack_trace(struct stack_trac
 {
 	int i, j;
 
+	if (WARN_ON(!trace->entries))
+		return;
+
 	for (i = 0; i < trace->nr_entries; i++) {
 		unsigned long ip = trace->entries[i];
 
Applied
#1 lore raw
Quoted 7 lines · Johannes Berg

This patch makes the stacktrace printout code warn when the entries pointer is unset rather than crashing when trying to access it in an attempt to make it a bit more robust.

I was saving a stacktrace into an skb and forgot to copy it across skb copies... Not sure if you want this, I have since fixed the code, but it would have been easier had the kernel not crashed in an interrupt.

applied, thanks Johannes.

I agree that such code needs to be more resilient, and resilience is mainly driven by observing random incidents as they happen in the field. So please keep sending such patches (even if they might seem dubious to you at first sight), they do make a lot of sense - and even if a patch does not end up getting applied your submission documents the incident.

Ingo