Patchwork [2/3] powerpc/fsl-booke: read buffer overflow

login
register
mail settings
Submitter Andrew Morton
Date Aug. 6, 2009, 11 p.m.
Message ID <200908062300.n76N0bnS028871@imap1.linux-foundation.org>
Download mbox | patch
Permalink /patch/30885/
State Accepted, archived
Delegated to: Kumar Gala
Headers show

Comments

Andrew Morton - Aug. 6, 2009, 11 p.m.
From: Roel Kluin <roel.kluin@gmail.com>

cam[tlbcam_index] is checked before tlbcam_index < ARRAY_SIZE(cam)

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/powerpc/mm/fsl_booke_mmu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Kumar Gala - Aug. 7, 2009, 2:27 a.m.
On Aug 6, 2009, at 6:00 PM, akpm@linux-foundation.org wrote:

> From: Roel Kluin <roel.kluin@gmail.com>
>
> cam[tlbcam_index] is checked before tlbcam_index < ARRAY_SIZE(cam)
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> arch/powerpc/mm/fsl_booke_mmu.c |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)


applied to next

- k

Patch

diff -puN arch/powerpc/mm/fsl_booke_mmu.c~powerpc-fsl-booke-read-buffer-overflow arch/powerpc/mm/fsl_booke_mmu.c
--- a/arch/powerpc/mm/fsl_booke_mmu.c~powerpc-fsl-booke-read-buffer-overflow
+++ a/arch/powerpc/mm/fsl_booke_mmu.c
@@ -161,7 +161,7 @@  unsigned long __init mmu_mapin_ram(void)
 	unsigned long virt = PAGE_OFFSET;
 	phys_addr_t phys = memstart_addr;
 
-	while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) {
+	while (tlbcam_index < ARRAY_SIZE(cam) && cam[tlbcam_index]) {
 		settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], PAGE_KERNEL_X, 0);
 		virt += cam[tlbcam_index];
 		phys += cam[tlbcam_index];