[31/37] mm: fix possible off-by-one in walk_pte_range()
From: Greg KH
Date: Tue Apr 29 2008 - 13:32:48 EST
2.6.25-stable review patch. If anyone has any objections, please let us
know.
------------------
From: Johannes Weiner <hannes@xxxxxxxxxxxx>
commit 556637cdabcd5918c7d4a1a2679b8f86fc81e891 upstream
After the loop in walk_pte_range() pte might point to the first address after
the pmd it walks. The pte_unmap() is then applied to something bad.
Spotted by Roel Kluin and Andreas Schwab.
Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxxx>
Cc: Roel Kluin <12o3l@xxxxxxxxxx>
Cc: Andreas Schwab <schwab@xxxxxxx>
Acked-by: Matt Mackall <mpm@xxxxxxxxxxx>
Acked-by: Mikael Pettersson <mikpe@xxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
mm/pagewalk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -9,11 +9,15 @@ static int walk_pte_range(pmd_t *pmd, un
int err = 0;
pte = pte_offset_map(pmd, addr);
- do {
+ for (;;) {
err = walk->pte_entry(pte, addr, addr + PAGE_SIZE, private);
if (err)
break;
- } while (pte++, addr += PAGE_SIZE, addr != end);
+ addr += PAGE_SIZE;
+ if (addr == end)
+ break;
+ pte++;
+ }
pte_unmap(pte);
return err;
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/