Re: [PATCH] x86/uaccess: Avoid barrier_nospec() in copy_from_user()
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2024-10-23 23:32:32
Attachments
- patch.diff [text/x-patch] 3011 bytes · preview
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2024-10-23 23:32:32
On Wed, 23 Oct 2024 at 13:07, Linus Torvalds [off-list ref] wrote:
Well, it boots. The code generation (from strncpy_from_user()) seems ok:
Actually, doing some more sanity checking, that patch is wrong.
Not *badly* wrong, but for some reason I did the "sbb" in 32-bit
(quite intentionally, but it's very wrong: I for some reason mentally
went "32-bit sign-extends to 64-bit")
I'd blame the fact that some of the very earliest x86-64 specs did
indeed do exactly that, but the reality is that it was just a
brainfart.
Anyway, the attached patch seems to actually _really_ work, and DTRT.
But considering that I created a 32-bit mask there for a while, maybe
somebody else should actually verify.
And I guess I should make "__put_user()" do the same thing, just so
that we only have one sequence. It probably doesn't matter for
put_user(), since there's no data leak coming out of it, but if
nothing else, avoiding non-canonical accesses from the kernel for any
non-LAM/LASS setup is probably just a good thing once we have this
logic.
Hmm?
Linus