Patchwork powerpc/oprofile: fix potential buffer overrun in op_model_cell.c

login
register
mail settings
Submitter Denis Kirjanov
Date June 1, 2010, 7:43 p.m.
Message ID <20100601194334.GA4549@hera.kernel.org>
Download mbox | patch
Permalink /patch/54291/
State Not Applicable
Headers show

Comments

Denis Kirjanov - June 1, 2010, 7:43 p.m.
Fix potential initial_lfsr buffer overrun.
Writing past the end of the buffer could happen when index == ENTRIES

Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
---
 arch/powerpc/oprofile/op_model_cell.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Robert Richter - June 4, 2010, 9:58 a.m.
On 01.06.10 15:43:34, Denis Kirjanov wrote:
> Fix potential initial_lfsr buffer overrun.
> Writing past the end of the buffer could happen when index == ENTRIES
> 
> Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>

Patch applied to

 git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent

Thanks Denis.

-Robert

Patch

diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index 2c9e522..7fd90d0 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -1077,7 +1077,7 @@  static int calculate_lfsr(int n)
 		index = ENTRIES-1;
 
 	/* make sure index is valid */
-	if ((index > ENTRIES) || (index < 0))
+	if ((index >= ENTRIES) || (index < 0))
 		index = ENTRIES-1;
 
 	return initial_lfsr[index];