Skip to content

Commit

Permalink
mm: fix NULL ptr deref when walking hugepages
Browse files Browse the repository at this point in the history
commit 08fa29d916c6e271ad13978cd993e7238c68db97 upstream.

A missing validation of the value returned by find_vma() could cause a
NULL ptr dereference when walking the pagetable.

This is triggerable from usermode by a simple user by trying to read a
page info out of /proc/pid/pagemap which doesn't exist.

Introduced by commit 025c5b2451e4 ("thp: optimize away unnecessary page
table locking").

Signed-off-by: Sasha Levin <[email protected]>
Reviewed-by: Naoya Horiguchi <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
sashalevin authored and bb-qq committed May 16, 2017
1 parent 1abb79d commit 98ce439
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,

/* find the first VMA at or above 'addr' */
vma = find_vma(walk->mm, addr);
if (pmd_trans_huge_lock(pmd, vma) == 1) {
if (vma && pmd_trans_huge_lock(pmd, vma) == 1) {
for (; addr != end; addr += PAGE_SIZE) {
unsigned long offset;

Expand Down

0 comments on commit 98ce439

Please sign in to comment.