linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Linus Torvalds' <torvalds@linux-foundation.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	"Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>,
	Waiman Long <longman@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Mark Rutland <mark.rutland@arm.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>
Subject: RE: [PATCH v3 2/6] x86/uaccess: Avoid barrier_nospec() in 64-bit __get_user()
Date: Sat, 16 Nov 2024 21:38:35 +0000	[thread overview]
Message-ID: <4055e18be7ff4f1f83fb9a4b6a8bc312@AcuMS.aculab.com> (raw)
In-Reply-To: <CAHk-=wgLCzEwa=S4hZFGeOPjix-1_fDrsqR-QLaBcDM-fgkvhw@mail.gmail.com>

From: Linus Torvalds
> Sent: 16 November 2024 01:27
> 
> On Fri, 15 Nov 2024 at 15:06, Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > It's sad that __get_user() is now slower than get_user() on x86, it kind
> > of defeats the whole point!
> 
> Well, honestly, we've been trying to get away from __get_user() and
> __put_user() for a long long time.
> 
> With CLAC/STAC, it's been probably a decade or two since __get_user()
> and friends were actually a worthwhile optimization, so let's just
> strive to get rid of the ones that matter.

Thinks....

If __get_user() is the same as get_user() then all the access_ok()
outside of get/put_user() and copy_to/from_user() can be removed
because they are pointless (anyone that brave?).
There is no point optimising the code to fast-path bad user pointers.

> We already have this with user_access_begin() + unsafe_get_user().
> There's also a version which masks the address: masked_user_access_begin().

That sounds as though it is begging for a simple to use:
	masked_addr = user_access_begin(addr, size, error_label);
and
	val = unsafe_get_user(masked_addr, error_label);
form?
Probably with objtool checking they are all in a valid sequence
with no functions calls (etc).

If address masking isn't needed (by an architecture) the address can be left
unchanged.

A quick grep shows access_ok() in 66 .c and 8 .h files outside the arch code.
And 69 .c file in arch, most of the arch .h are uaccess.h and futex.h.
I suspect the audit wouldn't tale that long.
Getting any patches accepted is another matter.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2024-11-16 21:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  1:56 [PATCH v3 0/6] x86/uaccess: avoid barrier_nospec() Josh Poimboeuf
2024-10-29  1:56 ` [PATCH v3 1/6] x86/uaccess: Avoid barrier_nospec() in 64-bit copy_from_user() Josh Poimboeuf
2024-10-29  8:13   ` Kirill A . Shutemov
2024-10-30  2:03   ` Linus Torvalds
2024-10-30  4:59     ` Josh Poimboeuf
2024-10-29  1:56 ` [PATCH v3 2/6] x86/uaccess: Avoid barrier_nospec() in 64-bit __get_user() Josh Poimboeuf
2024-10-29  3:27   ` Josh Poimboeuf
2024-11-08 17:12     ` David Laight
2024-11-15 23:06       ` 'Josh Poimboeuf'
2024-11-16  1:27         ` Linus Torvalds
2024-11-16 21:38           ` David Laight [this message]
2024-11-16 23:08             ` Linus Torvalds
2024-11-21 21:40           ` Josh Poimboeuf
2024-11-21 22:16             ` Linus Torvalds
2024-11-22  0:12               ` Josh Poimboeuf
2024-11-22  1:02                 ` Linus Torvalds
2024-11-22  3:11                   ` Josh Poimboeuf
2024-11-22  3:57                     ` Linus Torvalds
2024-11-22  9:06                       ` Christophe Leroy
2024-11-22 18:16                         ` Linus Torvalds
2024-11-22 19:13                       ` Linus Torvalds
2024-11-22 19:35                         ` Linus Torvalds
2024-11-24 16:11                           ` David Laight
2024-11-24 18:16                             ` Linus Torvalds
2024-11-22  9:38               ` David Laight
2024-10-29  1:56 ` [PATCH v3 3/6] x86/uaccess: Avoid barrier_nospec() in 32-bit copy_from_user() Josh Poimboeuf
2024-10-29  1:56 ` [PATCH v3 4/6] x86/uaccess: Convert 32-bit get_user() to unconditional pointer masking Josh Poimboeuf
2024-10-29  1:56 ` [PATCH v3 5/6] x86/uaccess: Avoid barrier_nospec() in 32-bit __get_user() Josh Poimboeuf
2024-10-29  1:56 ` [PATCH v3 6/6] x86/uaccess: Converge [__]get_user() implementations Josh Poimboeuf

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=4055e18be7ff4f1f83fb9a4b6a8bc312@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=longman@redhat.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).