Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33383
Change subject: nb/intel/nehalem: Prevent out of bounds read ......................................................................
nb/intel/nehalem: Prevent out of bounds read
Check that clock_speed_index is non-zero before decrementing it, else we will get a very large out of bounds array access.
Change-Id: Ic8ed1293adfe0866781bd638323977abd110777e Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1229675 --- M src/northbridge/intel/nehalem/raminit.c 1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/33383/1
diff --git a/src/northbridge/intel/nehalem/raminit.c b/src/northbridge/intel/nehalem/raminit.c index 15d6abb..72a2c57 100644 --- a/src/northbridge/intel/nehalem/raminit.c +++ b/src/northbridge/intel/nehalem/raminit.c @@ -598,7 +598,8 @@ for (clock_speed_index = 0; clock_speed_index < 3; clock_speed_index++) { if (cycletime == min_cycletime[clock_speed_index]) break; - if (cycletime > min_cycletime[clock_speed_index]) { + if (cycletime > min_cycletime[clock_speed_index] && + clock_speed_index != 0) { clock_speed_index--; cycletime = min_cycletime[clock_speed_index]; break;