Skip to content

Commit 30514ef

Browse files
joergroedelKAGA-KOKO
authored andcommitted
x86/mm/pti: Don't clear permissions in pti_clone_pmd()
The function sets the global-bit on cloned PMD entries, which only makes sense when the permissions are identical between the user and the kernel page-table. Further, only write-permissions are cleared for entry-text and kernel-text sections, which are not writeable at the end of the boot process. The reason why this RW clearing exists is that in the early PTI implementations the cloned kernel areas were set up during early boot before the kernel text is set to read only and not touched afterwards. This is not longer true. The cloned areas are still set up early to get the entry code working for interrupts and other things, but after the kernel text has been set RO the clone is repeated which copies the RO PMD/PTEs over to the user visible clone. That means the initial clearing of the writable bit can be avoided. [ tglx: Amended changelog ] Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Dave Hansen <[email protected]> Cc: "H . Peter Anvin" <[email protected]> Cc: [email protected] Cc: Linus Torvalds <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Brian Gerst <[email protected]> Cc: David Laight <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Greg KH <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Andrea Arcangeli <[email protected]> Cc: Waiman Long <[email protected]> Cc: Pavel Machek <[email protected]> Cc: "David H . Gutteridge" <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 88c6f8a commit 30514ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/x86/mm/pti.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static void __init pti_setup_vsyscall(void) { }
291291
#endif
292292

293293
static void
294-
pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
294+
pti_clone_pmds(unsigned long start, unsigned long end)
295295
{
296296
unsigned long addr;
297297

@@ -352,7 +352,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
352352
* tables will share the last-level page tables of this
353353
* address range
354354
*/
355-
*target_pmd = pmd_clear_flags(*pmd, clear);
355+
*target_pmd = *pmd;
356356
}
357357
}
358358

@@ -398,7 +398,7 @@ static void __init pti_clone_user_shared(void)
398398
start = CPU_ENTRY_AREA_BASE;
399399
end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES);
400400

401-
pti_clone_pmds(start, end, 0);
401+
pti_clone_pmds(start, end);
402402
}
403403
#endif /* CONFIG_X86_64 */
404404

@@ -418,8 +418,7 @@ static void __init pti_setup_espfix64(void)
418418
static void pti_clone_entry_text(void)
419419
{
420420
pti_clone_pmds((unsigned long) __entry_text_start,
421-
(unsigned long) __irqentry_text_end,
422-
_PAGE_RW);
421+
(unsigned long) __irqentry_text_end);
423422
}
424423

425424
/*
@@ -501,7 +500,7 @@ static void pti_clone_kernel_text(void)
501500
* pti_set_kernel_image_nonglobal() did to clear the
502501
* global bit.
503502
*/
504-
pti_clone_pmds(start, end_clone, _PAGE_RW);
503+
pti_clone_pmds(start, end_clone);
505504

506505
/*
507506
* pti_clone_pmds() will set the global bit in any PMDs

0 commit comments

Comments
 (0)