Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vsock: Use container_of() to get net namespace in sysctl handlers

current->nsproxy is should not be accessed directly as syzbot has found
that it could be NULL at times, causing crashes. Fix up the af_vsock
sysctl handlers to use container_of() to deal with the current net
namespace instead of attempting to rely on current.

This is the same type of change done in commit 7f5611cbc487 ("rds:
sysctl: rds_tcp_{rcv,snd}buf: avoid using current->nsproxy")

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
Link: https://patch.msgid.link/2026022318-rearview-gallery-ae13@gregkh
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Greg Kroah-Hartman and committed by
Jakub Kicinski
5cc61958 4b063c00

+2 -2
+2 -2
net/vmw_vsock/af_vsock.c
··· 2825 2825 if (write) 2826 2826 return -EPERM; 2827 2827 2828 - net = current->nsproxy->net_ns; 2828 + net = container_of(table->data, struct net, vsock.mode); 2829 2829 2830 2830 return __vsock_net_mode_string(table, write, buffer, lenp, ppos, 2831 2831 vsock_net_mode(net), NULL); ··· 2838 2838 struct net *net; 2839 2839 int ret; 2840 2840 2841 - net = current->nsproxy->net_ns; 2841 + net = container_of(table->data, struct net, vsock.child_ns_mode); 2842 2842 2843 2843 ret = __vsock_net_mode_string(table, write, buffer, lenp, ppos, 2844 2844 vsock_net_child_mode(net), &new_mode);