Skip to content

Commit

Permalink
mm: fix possible off-by-one in walk_pte_range()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Andreas Schwab <[email protected]>
Acked-by: Matt Mackall <[email protected]>
Acked-by: Mikael Pettersson <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Johannes Weiner authored and torvalds committed Apr 28, 2008
1 parent f022bfd commit 556637c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mm/pagewalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 556637c

Please sign in to comment.