Skip to content

Commit 8b1cb4a

Browse files
Hugh Dickinsakpm00
authored andcommitted
mm/pagewalk: fix EFI_PGT_DUMP of espfix area
Booting x86_64 with CONFIG_EFI_PGT_DUMP=y shows messages of the form "mm/pgtable-generic.c:53: bad pmd (____ptrval____)(8000000100077061)". EFI_PGT_DUMP dumps all of efi_mm, including the espfix area, which is set up with pmd entries which fit the pmd_bad() check: so 0d940a9 warns and clears those entries, which would ruin running Win16 binaries. The failing pte_offset_map() stopped such a kernel from even booting, until a few commits later be872f8 changed the pagewalk to tolerate that: but it needs to be even more careful, to not spoil those entries. I might have preferred to change init_espfix_ap() not to use "bad" pmd entries; or to leave them out of the efi_mm dump. But there is great value in staying away from there, and a pagewalk check of address against TASK_SIZE may protect from other such aberrations too. Link: https://lkml.kernel.org/r/[email protected] Closes: https://lore.kernel.org/linux-mm/CABXGCsN3JqXckWO=V7p=FhPU1tK03RE1w9UE6xL5Y86SMk209w@mail.gmail.com/ Fixes: 0d940a9 ("mm/pgtable: allow pte_offset_map[_lock]() to fail") Fixes: be872f8 ("mm/pagewalk: walk_pte_range() allow for pte_offset_map()") Signed-off-by: Hugh Dickins <[email protected]> Reported-by: Mikhail Gavrilov <[email protected]> Tested-by: Mikhail Gavrilov <[email protected]> Cc: Bagas Sanjaya <[email protected]> Cc: Laura Abbott <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent fa59895 commit 8b1cb4a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mm/pagewalk.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
4848
if (walk->no_vma) {
4949
/*
5050
* pte_offset_map() might apply user-specific validation.
51+
* Indeed, on x86_64 the pmd entries set up by init_espfix_ap()
52+
* fit its pmd_bad() check (_PAGE_NX set and _PAGE_RW clear),
53+
* and CONFIG_EFI_PGT_DUMP efi_mm goes so far as to walk them.
5154
*/
52-
if (walk->mm == &init_mm)
55+
if (walk->mm == &init_mm || addr >= TASK_SIZE)
5356
pte = pte_offset_kernel(pmd, addr);
5457
else
5558
pte = pte_offset_map(pmd, addr);

0 commit comments

Comments
 (0)