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

* Re: [PATCH] avoid out of bounds array reference in save_trace()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2009-12-09 22:34 UTC (permalink / raw)
  To: Luck, Tony; +Cc: mingo, luming.yu, linux-kernel

On Wed, 2009-12-09 at 14:29 -0800, Luck, Tony wrote:
> 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>

Thanks Tony,

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

> ---
> 
> 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

* [tip:core/urgent] lockdep: Avoid out of bounds array reference in save_trace()
  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-bot for Luck, Tony
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Luck, Tony @ 2009-12-10  7:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, tony.luck, tglx, mingo

Commit-ID:  ea5b41f9d595be354f7a50e56b28c2d72e6e88a5
Gitweb:     http://git.kernel.org/tip/ea5b41f9d595be354f7a50e56b28c2d72e6e88a5
Author:     Luck, Tony <tony.luck@intel.com>
AuthorDate: Wed, 9 Dec 2009 14:29:36 -0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Dec 2009 08:29:33 +0100

lockdep: Avoid out of bounds array reference in save_trace()

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>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: luming.yu@intel.com
LKML-Reference: <4b2024d085302c2a2@agluck-desktop.sc.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/lockdep.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 7a3ae56..4f8df01 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -386,7 +386,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