lkml.org 
[lkml]   [2009]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] avoid out of bounds array reference in save_trace()
Date
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;

\
 
 \ /
  Last update: 2009-12-09 23:31    [W:0.031 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site