Skip to content

Commit 5cc6195

Browse files
gregkhkuba-moo
authored andcommitted
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 7f5611c ("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: eafb64f ("vsock: add netns to vsock core") Link: https://patch.msgid.link/2026022318-rearview-gallery-ae13@gregkh Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4b063c0 commit 5cc6195

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/vmw_vsock/af_vsock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@ static int vsock_net_mode_string(const struct ctl_table *table, int write,
28252825
if (write)
28262826
return -EPERM;
28272827

2828-
net = current->nsproxy->net_ns;
2828+
net = container_of(table->data, struct net, vsock.mode);
28292829

28302830
return __vsock_net_mode_string(table, write, buffer, lenp, ppos,
28312831
vsock_net_mode(net), NULL);
@@ -2838,7 +2838,7 @@ static int vsock_net_child_mode_string(const struct ctl_table *table, int write,
28382838
struct net *net;
28392839
int ret;
28402840

2841-
net = current->nsproxy->net_ns;
2841+
net = container_of(table->data, struct net, vsock.child_ns_mode);
28422842

28432843
ret = __vsock_net_mode_string(table, write, buffer, lenp, ppos,
28442844
vsock_net_child_mode(net), &new_mode);

0 commit comments

Comments
 (0)