From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
linux-kernel@vger.kernel.org,
Bobby Eshleman <bobbyeshleman@meta.com>,
Jakub Kicinski <kuba@kernel.org>,
virtualization@lists.linux.dev, Paolo Abeni <pabeni@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Simon Horman <horms@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net 2/2] vsock: prevent child netns mode switch from local to global
Date: Thu, 12 Feb 2026 17:19:31 -0800 [thread overview]
Message-ID: <aY58I15Csp1CU8xI@devvm11784.nha0.facebook.com> (raw)
In-Reply-To: <20260212205916.97533-3-sgarzare@redhat.com>
On Thu, Feb 12, 2026 at 09:59:16PM +0100, Stefano Garzarella wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> A "local" namespace can change its `child_ns_mode` sysctl to "global",
> allowing nested namespaces to access global CIDs. This can be exploited
> by an unprivileged user who gained CAP_NET_ADMIN through a user
> namespace.
>
> Prevent this by rejecting writes that attempt to set `child_ns_mode` to
> "global" when the current namespace's mode is "local".
>
> Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
> Cc: bobbyeshleman@meta.com
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> net/vmw_vsock/af_vsock.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index 3b629b4a0359..9880756d9eff 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -95,8 +95,9 @@
> * the namespace's own ns_mode.
> *
> * Changing child_ns_mode only affects newly created namespaces, not the
> - * current namespace or existing children. At namespace creation, ns_mode
> - * is inherited from the parent's child_ns_mode.
> + * current namespace or existing children. A "local" namespace cannot set
> + * child_ns_mode to "global". At namespace creation, ns_mode is inherited
> + * from the parent's child_ns_mode.
> *
> * The init_net mode is "global" and cannot be modified.
> *
> @@ -2844,8 +2845,16 @@ static int vsock_net_child_mode_string(const struct ctl_table *table, int write,
> if (ret)
> return ret;
>
> - if (write)
> + if (write) {
> + /* Prevent a "local" namespace from escalating to "global",
> + * which would give nested namespaces access to global CIDs.
> + */
> + if (vsock_net_mode(net) == VSOCK_NET_MODE_LOCAL &&
> + new_mode == VSOCK_NET_MODE_GLOBAL)
> + return -EPERM;
> +
> vsock_net_set_child_mode(net, new_mode);
> + }
>
> return 0;
> }
> --
> 2.53.0
>
Thanks for the fix!
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
next prev parent reply other threads:[~2026-02-13 1:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 20:59 [PATCH net 0/2] vsock: fix child netns mode initialization and restriction Stefano Garzarella
2026-02-12 20:59 ` [PATCH net 1/2] vsock: fix child netns mode initialization Stefano Garzarella
2026-02-13 1:14 ` Bobby Eshleman
2026-02-12 20:59 ` [PATCH net 2/2] vsock: prevent child netns mode switch from local to global Stefano Garzarella
2026-02-13 1:19 ` Bobby Eshleman [this message]
2026-02-13 20:40 ` [PATCH net 0/2] vsock: fix child netns mode initialization and restriction patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aY58I15Csp1CU8xI@devvm11784.nha0.facebook.com \
--to=bobbyeshleman@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox