Commit ace88f10 authored by Thomas Hellstrom's avatar Thomas Hellstrom

mm: pagewalk: Take the pagetable lock in walk_pte_range()

Without the lock, anybody modifying a pte from within this function might
have it concurrently modified by someone else.

Cc: Matthew Wilcox <willy@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
parent ea81bae4
...@@ -10,8 +10,9 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ...@@ -10,8 +10,9 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
pte_t *pte; pte_t *pte;
int err = 0; int err = 0;
const struct mm_walk_ops *ops = walk->ops; 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 (;;) { for (;;) {
err = ops->pte_entry(pte, addr, addr + PAGE_SIZE, walk); err = ops->pte_entry(pte, addr, addr + PAGE_SIZE, walk);
if (err) if (err)
...@@ -22,7 +23,7 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ...@@ -22,7 +23,7 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
pte++; pte++;
} }
pte_unmap(pte); pte_unmap_unlock(pte, ptl);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment