[PATCH v2 0/3] uaccess: unify inline vs outline copy_{from,to}_user() selection

Yury Norov posted 3 patches 1 month, 2 weeks ago
arch/arc/include/asm/uaccess.h        |  3 +--
arch/arm/include/asm/uaccess.h        |  3 +--
arch/arm64/include/asm/uaccess.h      |  3 +--
arch/hexagon/include/asm/uaccess.h    |  3 +--
arch/loongarch/include/asm/uaccess.h  |  3 +--
arch/m68k/include/asm/uaccess.h       |  3 +--
arch/microblaze/include/asm/uaccess.h |  3 +--
arch/mips/include/asm/uaccess.h       |  3 +--
arch/nios2/include/asm/uaccess.h      |  3 +--
arch/openrisc/include/asm/uaccess.h   |  3 +--
arch/parisc/include/asm/uaccess.h     |  3 +--
arch/s390/include/asm/uaccess.h       |  3 +--
arch/sh/include/asm/uaccess.h         |  3 +--
arch/sparc/include/asm/uaccess_32.h   |  3 +--
arch/sparc/include/asm/uaccess_64.h   |  3 +--
arch/um/include/asm/uaccess.h         |  3 +--
arch/xtensa/include/asm/uaccess.h     |  3 +--
include/asm-generic/uaccess.h         |  3 +--
include/linux/uaccess.h               | 25 +++++++++----------------
lib/usercopy.c                        |  4 +---
rust/helpers/uaccess.c                |  2 +-
21 files changed, 29 insertions(+), 56 deletions(-)
[PATCH v2 0/3] uaccess: unify inline vs outline copy_{from,to}_user() selection
Posted by Yury Norov 1 month, 2 weeks ago
The kernel allows arches to select between inline and outline
implementations of the copy_{from,to}_user() by defining individual
INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER, correspondingly.
However, all arches enable or disable them always together.

Without the real use-case for one helper being inlined while the other
outlined, having independent controls is excessive and error prone.

The first patch of the series fixes rust/uaccess coppy_to_user() wrapper
guarded with INLINE_COPY_FROM_USER. The 2nd patch switches codebase to
the unified INLINE_COPY_USER. And the last patch cleans up ifdefery in
the include/linux/uaccess.h

---
v1: https://lore.kernel.org/all/20260325163313.749336-1-ynorov@nvidia.com/
v2:
 - reword cover letter (Andrew);
 - add v2#1 to fix rust/uaccess explicitly (Alice);

Yury Norov (3):
  rust: uaccess: use INLINE_COPY_TO_USER to guard copy_to_user()
  uaccess: unify inline vs outline copy_{from,to}_user() selection
  uaccess: minimize INLINE_COPY_USER-related ifdefery

 arch/arc/include/asm/uaccess.h        |  3 +--
 arch/arm/include/asm/uaccess.h        |  3 +--
 arch/arm64/include/asm/uaccess.h      |  3 +--
 arch/hexagon/include/asm/uaccess.h    |  3 +--
 arch/loongarch/include/asm/uaccess.h  |  3 +--
 arch/m68k/include/asm/uaccess.h       |  3 +--
 arch/microblaze/include/asm/uaccess.h |  3 +--
 arch/mips/include/asm/uaccess.h       |  3 +--
 arch/nios2/include/asm/uaccess.h      |  3 +--
 arch/openrisc/include/asm/uaccess.h   |  3 +--
 arch/parisc/include/asm/uaccess.h     |  3 +--
 arch/s390/include/asm/uaccess.h       |  3 +--
 arch/sh/include/asm/uaccess.h         |  3 +--
 arch/sparc/include/asm/uaccess_32.h   |  3 +--
 arch/sparc/include/asm/uaccess_64.h   |  3 +--
 arch/um/include/asm/uaccess.h         |  3 +--
 arch/xtensa/include/asm/uaccess.h     |  3 +--
 include/asm-generic/uaccess.h         |  3 +--
 include/linux/uaccess.h               | 25 +++++++++----------------
 lib/usercopy.c                        |  4 +---
 rust/helpers/uaccess.c                |  2 +-
 21 files changed, 29 insertions(+), 56 deletions(-)

-- 
2.51.0
Re: [PATCH v2 0/3] uaccess: unify inline vs outline copy_{from,to}_user() selection
Posted by Andrew Morton 1 month, 2 weeks ago
On Fri, 24 Apr 2026 22:08:54 -0400 Yury Norov <ynorov@nvidia.com> wrote:

> The kernel allows arches to select between inline and outline
> implementations of the copy_{from,to}_user() by defining individual
> INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER, correspondingly.
> However, all arches enable or disable them always together.
> 
> Without the real use-case for one helper being inlined while the other
> outlined, having independent controls is excessive and error prone.
> 
> The first patch of the series fixes rust/uaccess coppy_to_user() wrapper
> guarded with INLINE_COPY_FROM_USER. The 2nd patch switches codebase to
> the unified INLINE_COPY_USER. And the last patch cleans up ifdefery in
> the include/linux/uaccess.h

Seems sensible, thanks.  I'll queue these up for test-n-review.

Arnd was involved in some of the Fixes: commits and might be interested
in these changes, so Cc:.
Re: [PATCH v2 0/3] uaccess: unify inline vs outline copy_{from,to}_user() selection
Posted by Christophe Leroy (CS GROUP) 1 month, 2 weeks ago

Le 27/04/2026 à 17:58, Andrew Morton a écrit :
> On Fri, 24 Apr 2026 22:08:54 -0400 Yury Norov <ynorov@nvidia.com> wrote:
> 
>> The kernel allows arches to select between inline and outline
>> implementations of the copy_{from,to}_user() by defining individual
>> INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER, correspondingly.
>> However, all arches enable or disable them always together.
>>
>> Without the real use-case for one helper being inlined while the other
>> outlined, having independent controls is excessive and error prone.
>>
>> The first patch of the series fixes rust/uaccess coppy_to_user() wrapper
>> guarded with INLINE_COPY_FROM_USER. The 2nd patch switches codebase to
>> the unified INLINE_COPY_USER. And the last patch cleans up ifdefery in
>> the include/linux/uaccess.h
> 
> Seems sensible, thanks.  I'll queue these up for test-n-review.
> 
> Arnd was involved in some of the Fixes: commits and might be interested
> in these changes, so Cc:.
> 

I have an alternative as patch 2 in this series : 
https://lore.kernel.org/all/cover.1777306795.git.chleroy@kernel.org/

Christophe