[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fc087f38-2e14-41d1-8044-c054eb41ad19@csgroup.eu>
Date: Tue, 4 Nov 2025 07:30:32 +0100
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Thomas Gleixner <tglx@...utronix.de>, LKML <linux-kernel@...r.kernel.org>
Cc: kernel test robot <lkp@...el.com>, Russell King <linux@...linux.org.uk>,
linux-arm-kernel@...ts.infradead.org,
Linus Torvalds <torvalds@...ux-foundation.org>, x86@...nel.org,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>, Nicholas Piggin <npiggin@...il.com>,
linuxppc-dev@...ts.ozlabs.org, Paul Walmsley <pjw@...nel.org>,
Palmer Dabbelt <palmer@...belt.com>, linux-riscv@...ts.infradead.org,
Heiko Carstens <hca@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>, linux-s390@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Cooper <andrew.cooper3@...rix.com>,
David Laight <david.laight.linux@...il.com>,
Julia Lawall <Julia.Lawall@...ia.fr>, Nicolas Palix <nicolas.palix@...g.fr>,
Peter Zijlstra <peterz@...radead.org>, Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>, André Almeida
<andrealmeid@...lia.com>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
linux-fsdevel@...r.kernel.org
Subject: Re: [patch V5 08/12] uaccess: Provide put/get_user_inline()
Le 27/10/2025 à 09:43, Thomas Gleixner a écrit :
> Provide conveniance wrappers around scoped user access similiar to
> put/get_user(), which reduce the usage sites to:
>
> if (!get_user_inline(val, ptr))
> return -EFAULT;
>
> Should only be used if there is a demonstrable performance benefit.
>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Christophe Leroy <christophe.leroy@...roup.eu>
> ---
> V5: Rename to inline
> V4: Rename to scoped
> ---
> include/linux/uaccess.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> --- a/include/linux/uaccess.h
> +++ b/include/linux/uaccess.h
> @@ -825,6 +825,56 @@ for (bool done = false; !done; done = tr
> #define scoped_user_rw_access(uptr, elbl) \
> scoped_user_rw_access_size(uptr, sizeof(*(uptr)), elbl)
>
> +/**
> + * get_user_inline - Read user data inlined
> + * @val: The variable to store the value read from user memory
> + * @usrc: Pointer to the user space memory to read from
> + *
> + * Return: 0 if successful, -EFAULT when faulted
> + *
> + * Inlined variant of get_user(). Only use when there is a demonstrable
> + * performance reason.
> + */
> +#define get_user_inline(val, usrc) \
> +({ \
> + __label__ efault; \
> + typeof(usrc) _tmpsrc = usrc; \
> + int _ret = 0; \
> + \
> + scoped_user_read_access(_tmpsrc, efault) \
> + unsafe_get_user(val, _tmpsrc, efault); \
> + if (0) { \
> + efault: \
> + _ret = -EFAULT; \
> + } \
> + _ret; \
> +})
> +
> +/**
> + * put_user_inline - Write to user memory inlined
> + * @val: The value to write
> + * @udst: Pointer to the user space memory to write to
> + *
> + * Return: 0 if successful, -EFAULT when faulted
> + *
> + * Inlined variant of put_user(). Only use when there is a demonstrable
> + * performance reason.
> + */
> +#define put_user_inline(val, udst) \
> +({ \
> + __label__ efault; \
> + typeof(udst) _tmpdst = udst; \
> + int _ret = 0; \
> + \
> + scoped_user_write_access(_tmpdst, efault) \
> + unsafe_put_user(val, _tmpdst, efault); \
> + if (0) { \
> + efault: \
> + _ret = -EFAULT; \
> + } \
> + _ret; \
> +})
> +
> #ifdef CONFIG_HARDENED_USERCOPY
> void __noreturn usercopy_abort(const char *name, const char *detail,
> bool to_user, unsigned long offset,
>
Powered by blists - more mailing lists