summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/tsc.h
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2020-08-07 10:40:13 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-07 09:20:57 -0700
commit995909a4e22bc7b3ea3a71388cbb62ffebd76e7b (patch)
tree2b72f1c5f8a4759b66537a1536a0515fc527290c /arch/x86/include/asm/tsc.h
parent9bceb80b3cc483e6763c39a4928402fa82815d3e (diff)
downloadlinux-stable-995909a4e22bc7b3ea3a71388cbb62ffebd76e7b.tar.gz
linux-stable-995909a4e22bc7b3ea3a71388cbb62ffebd76e7b.tar.bz2
linux-stable-995909a4e22bc7b3ea3a71388cbb62ffebd76e7b.zip
x86/mm/64: Do not dereference non-present PGD entries
The code for preallocate_vmalloc_pages() was written under the assumption that the p4d_offset() and pud_offset() functions will perform present checks before dereferencing the parent entries. This assumption is wrong an leads to a bug in the code which causes the physical address found in the PGD be used as a page-table page, even if the PGD is not present. So the code flow currently is: pgd = pgd_offset_k(addr); p4d = p4d_offset(pgd, addr); if (p4d_none(*p4d)) p4d = p4d_alloc(&init_mm, pgd, addr); This lacks a check for pgd_none() at least, the correct flow would be: pgd = pgd_offset_k(addr); if (pgd_none(*pgd)) p4d = p4d_alloc(&init_mm, pgd, addr); else p4d = p4d_offset(pgd, addr); But this is the same flow that the p4d_alloc() and the pud_alloc() functions use internally, so there is no need to duplicate them. Remove the p?d_none() checks from the function and just call into p4d_alloc() and pud_alloc() to correctly pre-allocate the PGD entries. Reported-and-tested-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> Fixes: 6eb82f994026 ("x86/mm: Pre-allocate P4D/PUD pages for vmalloc area") Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/include/asm/tsc.h')
0 files changed, 0 insertions, 0 deletions