diff options
author | Johannes Weiner <hannes@saeurebad.de> | 2008-04-28 02:11:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 08:58:16 -0700 |
commit | 556637cdabcd5918c7d4a1a2679b8f86fc81e891 (patch) | |
tree | a5bb95b50e88535966af3ad49017196b757fca64 /mm/pagewalk.c | |
parent | f022bfd58253099102218db5249220a7f4787114 (diff) | |
download | linux-stable-556637cdabcd5918c7d4a1a2679b8f86fc81e891.tar.gz linux-stable-556637cdabcd5918c7d4a1a2679b8f86fc81e891.tar.bz2 linux-stable-556637cdabcd5918c7d4a1a2679b8f86fc81e891.zip |
mm: fix possible off-by-one in walk_pte_range()
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@saeurebad.de>
Cc: Roel Kluin <12o3l@tiscali.nl>
Cc: Andreas Schwab <schwab@suse.de>
Acked-by: Matt Mackall <mpm@selenic.com>
Acked-by: Mikael Pettersson <mikpe@it.uu.se>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/pagewalk.c')
-rw-r--r-- | mm/pagewalk.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 1cf1417ef8b7..0afd2387e507 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -9,11 +9,15 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, 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; |