Patchwork [4/4] powerpc: numa: avoid possible reference beyond property length in find_min_common_depth

login
register
mail settings
Submitter Milton Miller
Date Jan. 8, 2009, 12:19 p.m.
Message ID <1231417183_141716@mercury.realtime.net>
Download mbox | patch
Permalink /patch/17343/
State Accepted, archived
Commit 20fcefe5a0a354b0cc78ec4634d9f72dab5f1ee9
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Milton Miller - Jan. 8, 2009, 12:19 p.m.
find_min_common_depth was checking the property length incorrectly.
The value is in bytes not cells, and it is using the second entry.

Signed-off-By: Milton Miller <miltonm@bga.com>
---
I'm not aware of any trees that are broken in this way, so backport
not likely needed but easy to apply.

Patch

Index: work.git/arch/powerpc/mm/numa.c
===================================================================
--- work.git.orig/arch/powerpc/mm/numa.c	2009-01-05 05:08:10.000000000 -0600
+++ work.git/arch/powerpc/mm/numa.c	2009-01-05 05:10:25.000000000 -0600
@@ -260,7 +260,7 @@  static int __init find_min_common_depth(
 	ref_points = of_get_property(rtas_root,
 			"ibm,associativity-reference-points", &len);
 
-	if ((len >= 1) && ref_points) {
+	if ((len >= 2 * sizeof(unsigned int)) && ref_points) {
 		depth = ref_points[1];
 	} else {
 		dbg("NUMA: ibm,associativity-reference-points not found.\n");