* [PATCH net-next] net: Convert move_addr_to_user() to scoped user access
@ 2026-03-10 11:33 Christophe Leroy (CS GROUP)
2026-03-11 10:26 ` Eric Dumazet
2026-03-12 3:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-03-10 11:33 UTC (permalink / raw)
To: Eric Dumazet, Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn,
David S. Miller, Jakub Kicinski, Simon Horman
Cc: Christophe Leroy (CS GROUP), linux-kernel, netdev
move_addr_to_user() is a critical functions that was converted to
masked user access by commit 1fb0e471611d ("net: remove one stac/clac
pair from move_addr_to_user()")
Convert it to scoped user access to simplify the code.
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
---
net/socket.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 05952188127f..66eaf6d59941 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -280,23 +280,18 @@ static int move_addr_to_user(struct sockaddr_storage *kaddr, int klen,
BUG_ON(klen > sizeof(struct sockaddr_storage));
- if (can_do_masked_user_access())
- ulen = masked_user_access_begin(ulen);
- else if (!user_access_begin(ulen, 4))
- return -EFAULT;
-
- unsafe_get_user(len, ulen, efault_end);
-
- if (len > klen)
- len = klen;
- /*
- * "fromlen shall refer to the value before truncation.."
- * 1003.1g
- */
- if (len >= 0)
- unsafe_put_user(klen, ulen, efault_end);
+ scoped_user_rw_access_size(ulen, 4, efault_end) {
+ unsafe_get_user(len, ulen, efault_end);
- user_access_end();
+ if (len > klen)
+ len = klen;
+ /*
+ * "fromlen shall refer to the value before truncation.."
+ * 1003.1g
+ */
+ if (len >= 0)
+ unsafe_put_user(klen, ulen, efault_end);
+ }
if (len) {
if (len < 0)
@@ -309,7 +304,6 @@ static int move_addr_to_user(struct sockaddr_storage *kaddr, int klen,
return 0;
efault_end:
- user_access_end();
return -EFAULT;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: Convert move_addr_to_user() to scoped user access
2026-03-10 11:33 [PATCH net-next] net: Convert move_addr_to_user() to scoped user access Christophe Leroy (CS GROUP)
@ 2026-03-11 10:26 ` Eric Dumazet
2026-03-12 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-03-11 10:26 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn, David S. Miller,
Jakub Kicinski, Simon Horman, linux-kernel, netdev
On Tue, Mar 10, 2026 at 12:33 PM Christophe Leroy (CS GROUP)
<chleroy@kernel.org> wrote:
>
> move_addr_to_user() is a critical functions that was converted to
> masked user access by commit 1fb0e471611d ("net: remove one stac/clac
> pair from move_addr_to_user()")
>
> Convert it to scoped user access to simplify the code.
>
> Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: Convert move_addr_to_user() to scoped user access
2026-03-10 11:33 [PATCH net-next] net: Convert move_addr_to_user() to scoped user access Christophe Leroy (CS GROUP)
2026-03-11 10:26 ` Eric Dumazet
@ 2026-03-12 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-12 3:50 UTC (permalink / raw)
To: Christophe Leroy
Cc: edumazet, kuniyu, pabeni, willemb, davem, kuba, horms,
linux-kernel, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 10 Mar 2026 12:33:36 +0100 you wrote:
> move_addr_to_user() is a critical functions that was converted to
> masked user access by commit 1fb0e471611d ("net: remove one stac/clac
> pair from move_addr_to_user()")
>
> Convert it to scoped user access to simplify the code.
>
> Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
>
> [...]
Here is the summary with links:
- [net-next] net: Convert move_addr_to_user() to scoped user access
https://git.kernel.org/netdev/net-next/c/17edc4e820bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-12 3:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 11:33 [PATCH net-next] net: Convert move_addr_to_user() to scoped user access Christophe Leroy (CS GROUP)
2026-03-11 10:26 ` Eric Dumazet
2026-03-12 3:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox