Thread (16 messages) 16 messages, 5 authors, 2025-10-29

Re: [PATCH v1 1/2] uaccess: Add __user_write_access_begin().

From: David Laight <hidden>
Date: 2025-10-23 08:29:14
Also in: linux-riscv, linuxppc-dev, lkml

On Wed, 22 Oct 2025 19:37:27 -1000
Linus Torvalds [off-list ref] wrote:
On Wed, 22 Oct 2025 at 14:05, Kuniyuki Iwashima [off-list ref] wrote:
quoted
unsafe_put_user() can be used to save a stac/clac pair, but
masked_user_access_begin() or user_access_begin() introduces
an unnecessary address masking or access_ok().

Add a low-level helper for such a use case.  
I really suspect that you cannot actually measure the cost of the
extra masking, and would be much happier if you just used a regular
"user_access_begin()" (perhaps the "user_write_access_begin()"
variant).
Or wait for scoped_user_write_access() to get committed and then use that.

	David
The masking is very cheap - literally just a couple of ALU
instructions. And unless you can actually measure some real advantage
of avoiding it, let's not add another helper to this area.

We spent a fair amount of time undoing years of "__get_user()" and
"__put_user()" cases that didn't actually help, and sometimes only
made it hard to see where the actual user pointer validation was done.

               Linus
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help