From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
x86@kernel.org, Andrew Cooper <andrew.cooper3@citrix.com>,
Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH] x86: fix user address masking non-canonical speculation issue
Date: Wed, 23 Oct 2024 23:13:00 -0700 [thread overview]
Message-ID: <20241024061300.l5y4ng5gmkfrfdht@treble.attlocal.net> (raw)
In-Reply-To: <20241024013214.129639-1-torvalds@linux-foundation.org>
On Wed, Oct 23, 2024 at 06:31:59PM -0700, Linus Torvalds wrote:
> @@ -2389,6 +2390,15 @@ void __init arch_cpu_finalize_init(void)
> + /*
> + * Enable this when LAM is gated on LASS support
> + if (cpu_feature_enabled(X86_FEATURE_LAM))
> + USER_PTR_MAX = (1ul << 63) - PAGE_SIZE;
> + */
I'm probably missing something but once LAM is enabled, how wouldn't
this allow non-canonical address speculation? i.e. when bit 47/56 is
set and 63 is cleared, would it not go untouched by mask_user_address()
and thus be speculatively interpreted by AMD as a kernel address?
Also, the comment above __access_ok() now seems obsolete:
/*
* User pointers can have tag bits on x86-64. This scheme tolerates
* arbitrary values in those bits rather then masking them off.
*
* Enforce two rules:
* 1. 'ptr' must be in the user half of the address space
* 2. 'ptr+size' must not overflow into kernel addresses
*
* Note that addresses around the sign change are not valid addresses,
* and will GP-fault even with LAM enabled if the sign bit is set (see
* "CR3.LAM_SUP" that can narrow the canonicality check if we ever
* enable it, but not remove it entirely).
*
* So the "overflow into kernel addresses" does not imply some sudden
* exact boundary at the sign bit, and we can allow a lot of slop on the
* size check.
*
* In fact, we could probably remove the size check entirely, since
* any kernel accesses will be in increasing address order starting
* at 'ptr', and even if the end might be in kernel space, we'll
* hit the GP faults for non-canonical accesses before we ever get
* there.
*
* That's a separate optimization, for now just handle the small
* constant case.
*/
Other than the LAM question, it looks good to me and the code
generation+patching works as expected on a live system.
--
Josh
next prev parent reply other threads:[~2024-10-24 6:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 1:31 Linus Torvalds
2024-10-24 6:13 ` Josh Poimboeuf [this message]
2024-10-24 14:02 ` Kirill A. Shutemov
2024-10-24 15:42 ` Josh Poimboeuf
2024-10-24 17:35 ` Linus Torvalds
2024-10-24 18:47 ` Josh Poimboeuf
2024-10-25 18:52 ` Andrew Cooper
2024-10-25 9:01 ` Kirill A. Shutemov
2024-10-24 11:08 ` Borislav Petkov
2024-10-24 12:32 ` Kirill A. Shutemov
2024-10-24 13:02 ` Borislav Petkov
2024-10-24 17:53 ` Linus Torvalds
2024-10-24 18:13 ` Linus Torvalds
2024-10-24 19:09 ` Josh Poimboeuf
2024-10-24 20:00 ` Linus Torvalds
2024-10-25 11:24 ` Borislav Petkov
2024-10-24 14:09 ` Kirill A. Shutemov
2024-10-25 14:15 ` Maciej Wieczor-Retman
2024-10-25 17:41 ` Linus Torvalds
2024-10-25 19:00 ` Andrew Cooper
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=20241024061300.l5y4ng5gmkfrfdht@treble.attlocal.net \
--to=jpoimboe@kernel.org \
--cc=andrew.cooper3@citrix.com \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®