mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] avoid out of bounds array reference in save_trace()
@ 2009-12-09 22:29 Luck, Tony
  2009-12-09 22:34 ` Peter Zijlstra
  2009-12-10  7:50 ` [tip:core/urgent] lockdep: Avoid " tip-bot for Luck, Tony
  0 siblings, 2 replies; 3+ messages in thread
From: Luck, Tony @ 2009-12-09 22:29 UTC (permalink / raw)
  To: mingo, a.p.zijlstra, luming.yu; +Cc: linux-kernel

ia64 found this the hard way (because we currently have a stub for
save_stack_trace() that does nothing). But it would be a good idea to 
be cautious in case a real save_stack_trace() bailed out with an
error before it set trace->nr_entries.

Signed-off-by: Tony Luck <tony.luck@intel.com>

---

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 03c06af..429540c 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -387,7 +387,8 @@ static int save_trace(struct stack_trace *trace)
 	 * complete trace that maxes out the entries provided will be reported
 	 * as incomplete, friggin useless </rant>
 	 */
-	if (trace->entries[trace->nr_entries-1] == ULONG_MAX)
+	if (trace->nr_entries != 0 &&
+	    trace->entries[trace->nr_entries-1] == ULONG_MAX)
 		trace->nr_entries--;
 
 	trace->max_entries = trace->nr_entries;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-10  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09 22:29 [PATCH] avoid out of bounds array reference in save_trace() Luck, Tony
2009-12-09 22:34 ` Peter Zijlstra
2009-12-10  7:50 ` [tip:core/urgent] lockdep: Avoid " tip-bot for Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome