From: Nick Desaulniers <ndesaulniers@google.com>
To: Lee Jones <lee@kernel.org>
Cc: dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, x86@kernel.org, hpa@zytor.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] x86/mm/KASLR: Store pud_page_tramp into entry rather than page
Date: Wed, 14 Jun 2023 10:48:16 -0700 [thread overview]
Message-ID: <ZIn9YCcETx+Hlf6Z@google.com> (raw)
In-Reply-To: <20230614163859.924309-2-lee@kernel.org>
On Wed, Jun 14, 2023 at 05:38:54PM +0100, 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 <dave.hansen@linux.intel.com>
> Signed-off-by: Lee Jones <lee@kernel.org>
Nice work tracking this one down!
Fixes: 0925dda5962e ("x86/mm/KASLR: Use only one PUD entry for real mode trampoline")
Cc: <stable@vger.kernel.org>
> ---
> arch/x86/mm/kaslr.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
> index 557f0fe25dff4..37db264866b64 100644
> --- a/arch/x86/mm/kaslr.c
> +++ b/arch/x86/mm/kaslr.c
> @@ -172,10 +172,10 @@ void __meminit init_trampoline_kaslr(void)
> set_p4d(p4d_tramp,
> __p4d(_KERNPG_TABLE | __pa(pud_page_tramp)));
>
> - set_pgd(&trampoline_pgd_entry,
> - __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp)));
> + 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
>
next prev parent reply other threads:[~2023-06-14 17:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 16:38 [PATCH v2 0/1] x86: Fix .bss corruption Lee Jones
2023-06-14 16:38 ` [PATCH v2 1/1] x86/mm/KASLR: Store pud_page_tramp into entry rather than page Lee Jones
2023-06-14 17:48 ` Nick Desaulniers [this message]
2023-06-14 18:43 ` Lee Jones
2023-06-16 17:00 ` Lee Jones
2023-06-19 10:43 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZIn9YCcETx+Hlf6Z@google.com \
--to=ndesaulniers@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.