Re: [PATCH v2] vsock: ignore empty child namespace mode writes

From: Stefano Garzarella

Date: Tue Sep 15 2026 - 13:02:01 EST


CCing Bobby (and I guess you're missing several maintainers in CC)

On Tue, Sep 15, 2026 at 11:15:47AM -0300, Aldo Ariel Panzardo wrote:
__vsock_net_mode_string() returns success without updating new_mode when
the transfer length is zero. Its caller then reads the uninitialized enum
and may permanently store a stack-derived value in the write-once child
mode.

Return before inspecting or storing new_mode when no bytes were
transferred. This also prevents an empty write from locking the current
mode.

Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@xxxxxxxxx>
---
net/vmw_vsock/af_vsock.c | 2 ++
1 file changed, 2 insertions(+)

A changelog after --- or a reply to v1 to explain why sending a v2, would be nice to have.


diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 622dbd0467..816d25b314 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2883,6 +2883,8 @@ static int vsock_net_child_mode_string(const struct ctl_table *table, int write,
vsock_net_child_mode(net), &new_mode);
if (ret)
return ret;
+ if (!*lenp)
+ return 0;

Better to move this before calling __vsock_net_mode_string(), no?

That said, __vsock_net_mode_string() needs some cleanup IMO but I guess something for net-next.

Thanks,
Stefano


if (write) {
/* Prevent a "local" namespace from escalating to "global",
--
2.43.0