Skip to content

Commit

Permalink
mm: pagewalk: Take the pagetable lock in walk_pte_range()
Browse files Browse the repository at this point in the history
Without the lock, anybody modifying a pte from within this function might
have it concurrently modified by someone else.

Cc: Matthew Wilcox <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Huang Ying <[email protected]>
Cc: Jérôme Glisse <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Thomas Hellstrom <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
  • Loading branch information
thomashvmw committed Nov 6, 2019
1 parent ea81bae commit ace88f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mm/pagewalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
pte_t *pte;
int err = 0;
const struct mm_walk_ops *ops = walk->ops;
spinlock_t *ptl;

pte = pte_offset_map(pmd, addr);
pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
for (;;) {
err = ops->pte_entry(pte, addr, addr + PAGE_SIZE, walk);
if (err)
Expand All @@ -22,7 +23,7 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
pte++;
}

pte_unmap(pte);
pte_unmap_unlock(pte, ptl);
return err;
}

Expand Down

0 comments on commit ace88f1

Please sign in to comment.