set_pgd() expects to be passed whole pages to operate on, whereas
trampoline_pgd_entry is, as the name suggests, an entry. The
ramifications for using set_pgd() here are that the following thread of
execution will not only place the suggested value into the
trampoline_pgd_entry (8-Byte globally stored [.bss]) variable, PTI will
also attempt to replicate that value into the non-existent neighboring
user page (located +4k away), leading to the corruption of other global
[.bss] stored variables.
Suggested-by: Dave Hansen <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
---
arch/x86/mm/kaslr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 557f0fe25dff4..ee6f22f3385b6 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -175,7 +175,7 @@ void __meminit init_trampoline_kaslr(void)
set_pgd(&trampoline_pgd_entry,
__pgd(_KERNPG_TABLE | __pa(p4d_page_tramp)));
} else {
- set_pgd(&trampoline_pgd_entry,
- __pgd(_KERNPG_TABLE | __pa(pud_page_tramp)));
+ trampoline_pgd_entry =
+ __pgd(_KERNPG_TABLE | __pa(pud_page_tramp));
}
}
--
2.41.0.162.gfafddb0af9-goog
On Wed, 14 Jun 2023, Lee Jones wrote:
> set_pgd() expects to be passed whole pages to operate on, whereas
> trampoline_pgd_entry is, as the name suggests, an entry. The
> ramifications for using set_pgd() here are that the following thread of
> execution will not only place the suggested value into the
> trampoline_pgd_entry (8-Byte globally stored [.bss]) variable, PTI will
> also attempt to replicate that value into the non-existent neighboring
> user page (located +4k away), leading to the corruption of other global
> [.bss] stored variables.
>
> Suggested-by: Dave Hansen <[email protected]>
> Signed-off-by: Lee Jones <[email protected]>
> ---
> arch/x86/mm/kaslr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
> index 557f0fe25dff4..ee6f22f3385b6 100644
> --- a/arch/x86/mm/kaslr.c
> +++ b/arch/x86/mm/kaslr.c
> @@ -175,7 +175,7 @@ void __meminit init_trampoline_kaslr(void)
> set_pgd(&trampoline_pgd_entry,
> __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp)));
This needs converting too.
v2 in test.
> } else {
> - set_pgd(&trampoline_pgd_entry,
> - __pgd(_KERNPG_TABLE | __pa(pud_page_tramp)));
> + trampoline_pgd_entry =
> + __pgd(_KERNPG_TABLE | __pa(pud_page_tramp));
> }
> }
--
Lee Jones [李琼斯]