scm: use masked_user_access_begin() in put_cmsg()
Subsystems (3)
PATCH 1/1 scm: use masked_user_access_begin() in put_cmsg()
Use the greatest and latest uaccess construct to get an optimal code.
Before :
lea (%r9,%rcx,1),%r10 movabs $<USER_PTR_MAX>,%r11 mov $0xfffffff2,%eax cmp %rcx,%r10 jb ffffffff81cdc312 <put_cmsg+0x152> cmp %r11,%r10 ja ffffffff81cdc312 <put_cmsg+0x152> stac lfence mov %r9,(%rcx)
After:
movabs $<USER_PTR_MAX>,%r9 cmp %r9,%rax cmova %r9,%rax stac mov %rcx,(%rax)
Signed-off-by Eric Dumazet <[email protected]>
--- net/core/scm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/scm.c +3 -1
@@ -273,7 +273,9 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)check_object_size (data, cmlen -sizeof (*cm), true); -if (!user_write_access_begin (cm, cmlen)) +if (can_do_masked_user_access ()) + cm =masked_user_access_begin (cm); +else if (!user_write_access_begin (cm, cmlen)) goto efault;unsafe_put_user (cmlen, &cm->cmsg_len, efault_end);
Signature · 1 line
2.51.0.536.g15c5d4f767-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 15 lines · On Thu, 25 Sep 2025 22:49:14 +0000 you wrote:
Use the greatest and latest uaccess construct to get an optimal code.
Before :
lea (%r9,%rcx,1),%r10 movabs $<USER_PTR_MAX>,%r11 mov $0xfffffff2,%eax cmp %rcx,%r10 jb ffffffff81cdc312 <put_cmsg+0x152> cmp %r11,%r10 ja ffffffff81cdc312 <put_cmsg+0x152> stac lfence mov %r9,(%rcx)
Quoted 1 line
[...]
Here is the summary with links:
- [net-next] scm: use masked_user_access_begin() in put_cmsg()
https://git.kernel.org/netdev/net-next/c/2b235765e9d4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html