Re: [PATCH net] vsock: only deliver taps to namespaces that can reach the device
From: Bobby Eshleman
Date: Mon Nov 30 2026 - 11:22:15 EST
On Tue, Nov 24, 2026 at 09:43:46AM +0100, Stefano Garzarella wrote:
> On Mon, Nov 23, 2026 at 08:18:47AM -0800, Bobby Eshleman wrote:
> > On Mon, Nov 23, 2026 at 02:17:54PM +0100, Stefano Garzarella wrote:
> > > On Mon, Nov 23, 2026 at 12:58:38PM +0100, Paolo Abeni wrote:
> > > > On 11/23/26 10:43, Stefano Garzarella wrote:
> > > > > On Mon, Nov 16, 2026 at 03:46:49PM -0800, Bobby Eshleman wrote:
> > > > > > vsock_deliver_tap() clones every packet to every vsockmon device on the
> > > > > > system. Creating one needs only CAP_NET_ADMIN in the owning user
> > > > > > namespace, so an unprivileged user can capture the traffic of local mode
> > > > > > namespaces.
> > > > > >
> > > > > > Pass the packet's netns to vsock_deliver_tap() and only deliver to
> > > > > > devices that pass vsock_net_check_mode(), the same rule socket lookups
> > > > > > use. vhost passes the vhost_vsock netns, loopback the sending socket's
> > > > > > netns, and virtio-vsock NULL (global mode).
> > > > >
> > > > > For local namespaces I think we are fine, but what about global?
> > > > >
> > > > > Is it okay that a namespace with global can capture all the packets of other global namespaces?
> > > > >
> > > > > Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?
> > > > My take is that the above question is quite orthogonal to the current patch
> > > > and may impact old applications relying on the legacy behavior.
> > >
> > > True, but I'm not sure that behavior was correct since the beginning.
> > > E.g., what is the point of having CAP_NET_ADMIN requirement if an
> > > unprivileged user can just crate a new namespace and get it?
> > >
> > > Anyway, it's eventually pre-existing netns support in vsock, so it should be
> > > fixed with a followup.
> > >
> > >
> > > Reviewed-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
> > >
> > > Thanks,
> > > Stefano
> > >
> >
> > Its a fair point and I agree we should take it up in a follow up. My
> > current instinct is that CAP_NET_ADMIN probably shouldn't be enforced
> > for some (all?) of these global-mode paths.
>
> Why not?
What I mean to say is we should probably only be doing those checks if
it was required prior to all of the netns work to have cap net admin. I
don't think we we were intending to change the permissions model for
global namespaces... though without checking I'm not 100% confident yet
which permissions a user would need to a) setup a vsock tap or b) read
from it. I'll have to give it a deeper look.
>
> I should take a closer look at what’s going on with the NICs, what
> permissions does someone intercepting traffic need to have?
>
> Ideally, even though the addressing is global, maybe we should set it up so
> that within a namespace, you can only observe traffic generated by that
> namespace or its children.
>
> But honestly, I don’t know how complicated that is. In fact, if you want
> isolation, you have to enable “local,” and at that point, with this patch,
> we’re all set.
>
> Thanks,
> Stefano
Let's consider it. Worth giving this all a second look.
Best,
Bobby