linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/4] uaccess: Provide and use helpers for user masked access
@ 2025-08-13 15:57 Thomas Gleixner
  2025-08-13 15:57 ` [patch 1/4] uaccess: Provide common helpers for masked user access Thomas Gleixner
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Thomas Gleixner @ 2025-08-13 15:57 UTC (permalink / raw)
  To: LKML
  Cc: Linus Torvalds, Mathieu Desnoyers, Peter Zijlstra, Darren Hart,
	Davidlohr Bueso, André Almeida, x86, Alexander Viro,
	Christian Brauner, Jan Kara, linux-fsdevel

commit 2865baf54077 ("x86: support user address masking instead of
non-speculative conditional") provided an optimization for
unsafe_get/put_user(), which optimizes the Spectre-V1 mitigation in an
architecture specific way. Currently only x86_64 supports that.

The required code pattern screams for helper functions before it is copied
all over the kernel. So far the exposure is limited to futex, x86 and
fs/select.

Provide a set of helpers for common single size access patterns:

  - get/put_user_masked_uNN() where $NN is the variable size in
    bits, i.e. 8, 16, 32, 64.

  - user_read/write_masked_begin() for scenarios, where several
    unsafe_put/get_user() invocations are required.

Convert the existing users over to this.

The series applies on top of

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/urgent

which has a bug fix pending for the futex implementation of this.

It's also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git uaccess/masked

there is another candidate for conversion: RSEQ. This has not been
converted yet because there are more severe performance issues with this
code, which starts to become prominent in exit path profiling because glibc
started to use it. This will be addressed in a seperate series.

As this creates dependencies, merging it should go through one central tree,
i.e. tip, but that's a debate for later :)

Thanks,

	tglx
---
 arch/x86/include/asm/futex.h |   12 ++----
 fs/select.c                  |    4 --
 include/linux/uaccess.h      |   78 +++++++++++++++++++++++++++++++++++++++++++
 kernel/futex/futex.h         |   37 +-------------------
 4 files changed, 85 insertions(+), 46 deletions(-)




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-08-26  7:22 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 15:57 [patch 0/4] uaccess: Provide and use helpers for user masked access Thomas Gleixner
2025-08-13 15:57 ` [patch 1/4] uaccess: Provide common helpers for masked user access Thomas Gleixner
2025-08-26  7:04   ` Christophe Leroy
2025-08-13 15:57 ` [patch 2/4] futex: Convert to get/put_user_masked_u32() Thomas Gleixner
2025-08-13 15:57 ` [patch 3/4] x86/futex: Use user_*_masked_begin() Thomas Gleixner
2025-08-26  7:09   ` Christophe Leroy
2025-08-13 15:57 ` [patch 4/4] select: Use user_read_masked_begin() Thomas Gleixner
2025-08-17 13:49 ` [patch 0/4] uaccess: Provide and use helpers for user masked access David Laight
2025-08-17 14:00   ` Linus Torvalds
2025-08-17 15:29     ` David Laight
2025-08-17 15:36       ` Linus Torvalds
2025-08-18 11:59         ` David Laight
2025-08-18 21:21   ` David Laight
2025-08-18 21:36     ` Linus Torvalds
2025-08-18 22:21       ` Al Viro
2025-08-18 23:00         ` Linus Torvalds
2025-08-19  0:39           ` Al Viro
2025-08-20 23:48             ` Al Viro
2025-08-21  7:45               ` Christian Brauner
2025-08-21 22:49                 ` Al Viro
2025-08-19  2:39       ` Matthew Wilcox
2025-08-19 21:33       ` David Laight
2025-08-19  4:44     ` Thomas Weißschuh

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).