summaryrefslogtreecommitdiff
path: root/net/socket.c
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2023-10-16 06:47:39 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-09-12 11:11:34 +0200
commit4a746fb253fa7c2908b3f317d37d8c0202d5f278 (patch)
treec002ba42d1dc418778b1b415016d131adc73de22 /net/socket.c
parent07200e313cb5b594c9e984a441896b73438972b3 (diff)
downloadlinux-rpi-4a746fb253fa7c2908b3f317d37d8c0202d5f278.tar.gz
linux-rpi-4a746fb253fa7c2908b3f317d37d8c0202d5f278.tar.bz2
linux-rpi-4a746fb253fa7c2908b3f317d37d8c0202d5f278.zip
bpf: Add sockptr support for getsockopt
[ Upstream commit a615f67e1a426f35366b8398c11f31c148e7df48 ] The whole network stack uses sockptr, and while it doesn't move to something more modern, let's use sockptr in getsockptr BPF hooks, so, it could be used by other callers. The main motivation for this change is to use it in the io_uring {g,s}etsockopt(), which will use a userspace pointer for *optval, but, a kernel value for optlen. Link: https://lore.kernel.org/all/ZSArfLaaGcfd8LH8@gmail.com/ Signed-off-by: Breno Leitao <leitao@debian.org> Acked-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20231016134750.1381153-2-leitao@debian.org Signed-off-by: Jens Axboe <axboe@kernel.dk> Stable-dep-of: 33f339a1ba54 ("bpf, net: Fix a potential race in do_sock_getsockopt()") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/socket.c b/net/socket.c
index 8d83c4bb163b..b2d75d5661be 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2375,8 +2375,9 @@ int __sys_getsockopt(int fd, int level, int optname, char __user *optval,
if (!in_compat_syscall())
err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname,
- optval, optlen, max_optlen,
- err);
+ USER_SOCKPTR(optval),
+ USER_SOCKPTR(optlen),
+ max_optlen, err);
out_put:
fput_light(sock->file, fput_needed);
return err;