mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 05:51:14 -04:00
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 commit7f5611cbc4("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:eafb64f40c("vsock: add netns to vsock core") Link: https://patch.msgid.link/2026022318-rearview-gallery-ae13@gregkh Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
4b063c002c
commit
5cc619583c
@@ -2825,7 +2825,7 @@ static int vsock_net_mode_string(const struct ctl_table *table, int write,
|
||||
if (write)
|
||||
return -EPERM;
|
||||
|
||||
net = current->nsproxy->net_ns;
|
||||
net = container_of(table->data, struct net, vsock.mode);
|
||||
|
||||
return __vsock_net_mode_string(table, write, buffer, lenp, ppos,
|
||||
vsock_net_mode(net), NULL);
|
||||
@@ -2838,7 +2838,7 @@ static int vsock_net_child_mode_string(const struct ctl_table *table, int write,
|
||||
struct net *net;
|
||||
int ret;
|
||||
|
||||
net = current->nsproxy->net_ns;
|
||||
net = container_of(table->data, struct net, vsock.child_ns_mode);
|
||||
|
||||
ret = __vsock_net_mode_string(table, write, buffer, lenp, ppos,
|
||||
vsock_net_child_mode(net), &new_mode);
|
||||
|
||||
Reference in New Issue
Block a user