From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C031D3AF662 for ; Fri, 18 Sep 2026 14:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789741682; cv=none; b=M4WQw0JGmlsepV5p5tYTW+P1kiJhl4NlkxqJFK6/KRiPy78Ybu+MwKf5o+5Fhac0d1ksawQP1XUmhGWdh60akvQSRZbmyvzUJMYcCshFfRxC36vIqr+vMs1Lqd1i+l2oqrANZkjV3paRvHLpPOW+jZVCM0FKt+dKSpCldaTBpyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789741682; c=relaxed/simple; bh=qWPM8mEcQAiZiBe5wIuy4aqUTDeswnrEyUyg1zkQHi0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ph2fqyOVDIgSxJ2z8BrCBHQkl5AwySveJPsFHhR7j0ZQow6E3Uw+ZgUGOfzUsODCr4d0jXqzZOr4Nu6z8NiUKdomVETBJuYkbFUeVSIvPTlzsd3VdXxxzH4Snxj8Zr95kTUaWfjqJ9+lJktBsr2BwHf2xx57x1CUQoYTx8XZC9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LpgSBRZ5; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=U61/uDEf; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LpgSBRZ5"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="U61/uDEf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789741678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tzy4rg64m2nfrHznucdcUVmAGxkvGHwxFBaPQdjr128=; b=LpgSBRZ5zdBjIaf01/O6nqV4COH0L6BRAtehULdDUHkfislYaW/gOFzNMJVj6ZVEIjft0x YKLKYKpHApQ1dFcDNfdKpflF/X4pMo0GkfluBT8lY11gClwZx7Do68oUAP/eY3Vka0hDbv koa+7oFHnnNJWpAgVr98EjPSQdn8LJY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-YA-aihrCPuC_JXhHyFfJkA-1; Fri, 18 Sep 2026 10:27:54 -0400 X-MC-Unique: YA-aihrCPuC_JXhHyFfJkA-1 X-Mimecast-MFC-AGG-ID: YA-aihrCPuC_JXhHyFfJkA_1789741674 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4955e865174so5008445e9.3 for ; Fri, 18 Sep 2026 07:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789741673; x=1790346473; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Tzy4rg64m2nfrHznucdcUVmAGxkvGHwxFBaPQdjr128=; b=U61/uDEffANFsZZwQ12ed6ezA26j+XuCSfi2k6R6pCeFf+udfNWqqwi5PV4yUJcCZW URWJPGwhanmZUy48UFPgiHQ2NlzDejnLaswR6bd6CnVC3D1l2I1FA8q9xQNGYcz2mAYr jSdgLj20iJLb8VpY6FO/JRx09deYgEs6QsJFqYq4PxLugNGcex7n4qY8lFApIZLvMIhz cWwe6z7ySjxtCMZF9aZmfinAcNcg2GtnTtCoHe3GtE02es8GWeRk8gxeHAS7b9SST3d9 SqeKkXdUo1t0R78rNYuJAei2dyF8KdSQ0Mw6a5LzQbu1+RCCqIpQ68bK/C+AJVGmkKMw ypsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789741673; x=1790346473; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Tzy4rg64m2nfrHznucdcUVmAGxkvGHwxFBaPQdjr128=; b=lSGsz4NLRdHt213KyH4+Yq9NflPJkjqBQjKVA/a5di2lglG4rAhoXj6VLp6KITMVkG sKFzC/BI6KXAM24bVb3Mljni0W0Q2jSQS/+eMluV/4FD+e4kwCYbX/CLS7yWREL0A1Kz OcB1A0jeeEVIjbsNX3dupSDgBMXObz4zzLTQtGg1tSDa/SQItRS37JRXZVuq/RLMCdxl S1xEB28acG4Q2/7Jc4w3LaUFjM1zKNF8U3FlvfRsGlLe9D77ZabKx/9UGLiLduzyQt1I thhnrsX8eF/gPAqquGQ9oHcvInV3MATHVYnqLVNx7uFFxR/Te/1aqmLQpKRMr3zvuSyo XdkA== X-Forwarded-Encrypted: i=1; AKwUvByujS0lqeuep+RJ25vt4g8+za0uXFyPHXYE+QuTP18KAm0SAKcrkS7DkxDIkCuDxauDdp/OUVs=@vger.kernel.org X-Gm-Message-State: AFuF++kRn2jgtmSY7TqCdrcFqgbz5/umxKA2c5YY1BCKNDYc2sHvvm3V mHlbqy5zGkERWRMNx7T2VjENq+MkS0RvlZlqLSWktJnu+ZVkSngEXNQjrJechFACN9gozF8C3NY 7Hn5aJd+loJGvAkq6FYwji6o5XSvg5k6tQhCA/MLWP38VKtV1pVON2lJcdA== X-Gm-Gg: AYBFou1eklkYuQ1RDpiunlT2ziIaC/i0qNvbhLfpsGaMMDdnL4u2kWjw6VEQMWDRCmh nkzBGb6exVBRi5tXO6MGuD15cpHgI8/NdivWvHfFd3PMruuSiLbHgq4q+/HJtOVKywDLtXPzqVz X9+S0ApTL0rd+S4POKYBshEkA6nEbJwqXZWWeG0eSNCdyXNunRUHsnaFfohbHdO+DwCKyv8WX4p eT+2bpTFtbQalv0t7AhHWpvB6VCB4tSx1hIk0EJiHk8jtRSqSrvOZc4obX4ZgzOn+WSfXnAFjmz 0q5QdQ8Z8D2t0WlZpMcVg3y8n3igipTeB//vRRUNVQlOvCAitSjqCFNCwHHaDrMjwJOGd+DiH14 0oGKLd1NjJQG5cbB0NbM+IbbI24qKnu1/oNrzvWbQarKjkQ== X-Received: by 2002:a05:600d:4449:10b0:49f:cc2a:f73a with SMTP id 5b1f17b1804b1-49fcc2af743mr10053735e9.25.1789741673578; Fri, 18 Sep 2026 07:27:53 -0700 (PDT) X-Received: by 2002:a05:600d:4449:10b0:49f:cc2a:f73a with SMTP id 5b1f17b1804b1-49fcc2af743mr10053175e9.25.1789741672904; Fri, 18 Sep 2026 07:27:52 -0700 (PDT) Received: from sgarzare-redhat (host-79-53-30-11.retail.telecomitalia.it. [79.53.30.11]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48720081426sm4196721f8f.33.2026.09.18.07.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 07:27:52 -0700 (PDT) Date: Fri, 18 Sep 2026 16:27:46 +0200 From: Stefano Garzarella To: Bobby Eshleman Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Shuah Khan , Randy Dunlap , virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, sargun@sargun.me, jlinbox@meta.com, Bobby Eshleman Subject: Re: [PATCH net-next 2/6] vsock: add IOCTL_VM_SOCKETS_ASSIGN_G2H_NETNS Message-ID: References: <20260902-vsock-guest-ns-v1-0-9995383e9a8b@meta.com> <20260902-vsock-guest-ns-v1-2-9995383e9a8b@meta.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On Wed, Sep 16, 2026 at 02:23:48PM -0700, Bobby Eshleman wrote: >On Wed, Sep 16, 2026 at 02:57:43PM +0200, Stefano Garzarella wrote: >> On Tue, Sep 15, 2026 at 11:50:10AM -0700, Bobby Eshleman wrote: >> > On Tue, Sep 15, 2026 at 05:28:25PM +0200, Stefano Garzarella wrote: >> > > On Wed, Sep 02, 2026 at 04:00:48PM -0700, Bobby Eshleman wrote: >> > > > From: Bobby Eshleman >> > > > >> > > > Namespaces let a host isolate a VM's vsock traffic to a specific >> > > > namespace, but in a guest vsock traffic cannot be isolated to a >> > > > namespace. The vsock device is hardcoded to global mode and can't be >> > > > moved into a local-mode namespace. >> > > > >> > > > Introduce ioctl IOCTL_VM_SOCKETS_ASSIGN_G2H_NETNS on /dev/vsock that >> > > >> > > We already discussed about netlink, but I'm not sure how much work can >> > > take, here just another alternative, what about adding >> > > /proc/sys/net/vsock/g2h_owner sysctl that can be read/write where: >> > > 0 - no owner >> > > 1 - owner >> > > >> > > 0 -> 1 transition, move the device in the new nets >> > > 1 -> 0 transition, reset back to init_ns >> > >> > That seems reasonable, but if multi-device support ever lands, this >> > might be harder to adapt cleanly? >> >> I see, but maybe we can have a dev0/ dev1/ subfolders in that case. >> >> > >> > > >> > > > gives userspace a way to move the device to the calling pid's namespace. >> > > > The call requires CAP_NET_ADMIN in the root user namespace. A privileged >> > > > user wishing to "unassign" the device can move it to the init_netns, >> > > > which is hardcoded to global mode (so no unassign call is necessary). >> > > > >> > > > A getter to read the current assignment back was considered, returning >> > > > either the namespace's net_cookie or its nsfs inode number, but neither >> > > > seemed useful enough to bake into the uAPI now. It can be added later if >> > > > a user turns up that needs it. >> > > > >> > > > Add a transport hook to indicate support for guest namespacing, so that >> > > > transports may opt in/out. A transport that opts out keeps the >> > > > reachability rules it had before this ioctl existed. >> > > > >> > > > Sockets are reset when the underlying device moves to a different >> > > > namespace, so as to prevent reachability from the previous and now >> > > > disallowed namespace. >> > > > >> > > > Following the approach of netdevs, the device returns to init_net when >> > > > its namespace is removed. Care is taken to not break flows when the >> > > > device is inside a global namespace that is being torn down and alive >> > > > sockets are in a different global namespace. In this scenario, the >> > > > device's netns getter pre-emptively falls back to the init_net (always >> > > > global) so that these flows are not disrupted. If init_netns ever >> > > > supports local-mode in the future, this logic will have to be changed. >> > > > >> > > > Suggested-by: Stefano Garzarella >> > > > Link: https://lore.kernel.org/all/20200427142518.uwssa6dtasrp3bfc@steredhat/ >> > > > Signed-off-by: Bobby Eshleman >> > > > --- >> > > > Documentation/admin-guide/sysctl/net.rst | 18 +++ >> > > > include/net/af_vsock.h | 7 ++ >> > > > include/uapi/linux/vm_sockets.h | 6 + >> > > > net/vmw_vsock/af_vsock.c | 198 ++++++++++++++++++++++++++++++- >> > > > 4 files changed, 228 insertions(+), 1 deletion(-) >> > > > >> >> [...] >> >> > >> > One thing I realized when answering your uAPI questions and looking at >> > the code is that IOCTL_VM_SOCKETS_GET_LOCAL_CID is not namespace aware, >> > but I think it probably should be? I remember for host ns we strived for >> > truly strong isolation. >> >> Can you elabore a bit more? >> > >I'm wondering if IOCTL_VM_SOCKETS_GET_LOCAL_CID should not reveal the Okay, I see now, too many IOCTL_VM_SOCKETS involved and I didn't get you were referring to the GET_LOCAL_CID xD >CID of the g2h device if the device has been moved to an inaccessible >namespace? In this case, fallback to the results of h2g/local and >through to returning VMADDR_CID_ANY if neither of those transports are >loaded. Yeah, I agree. I'm not 100% sure if it's really an issue if we reveal it to any workspace, but I also don't see why we should do that. So, yeah, if possible we should reveal it only in the namespace assigned to the G2H. > >I also considered whether or not /dev/vsock should even be visible from >within an inaccessible namespace in order to not leak even the mere >presence of the vsock device, but it seems to me that /dev/vsock's >presence doesn't leak anything besides the presence of the vsock module. > Will this break userspace doing IOCTL_VM_SOCKETS_GET_LOCAL_CID on loopback, etc. ? Thanks, Stefano