From nobody Thu Oct 9 04:15:10 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 1805122689C for ; Fri, 20 Jun 2025 19:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750449187; cv=none; b=fnVCV4he/swG5JSJw5rexAvZ/Sa3+w6zNnuDgbVSU+5p3cMLiVEVL6k82eCflh1o0/nJ0bs/C+LiGSKEdOie/fyTwvw9CC6+FFmieniz4pZ0a8XtVZN1KajXCauUvUOQdogEXM3L9XuYfEaLdGBqs1RLff+P2grieTsrpIAN9Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750449187; c=relaxed/simple; bh=IA1v21XSYp9brpbYgXg7OcdfSvZaDksDvp3fz0pIJCk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eTXofoS6LIhceZkPcTfFeneUb1a5KSQwCeHnTFbzjaT4vYRpwcxswzRyprCWCixkVDgUmSsQ4Pb2F1IIw6MzV8n+1usvqOt1l4nIBt9C5RK2XmddtLwBAedXrEPIKjvgiGP8INMhBadSx5lZVhPSaCia2pEiBgxjPyhanlUHaa0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co; spf=pass smtp.mailfrom=rbox.co; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b=bzkagKWh; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rbox.co Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rbox.co Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rbox.co header.i=@rbox.co header.b="bzkagKWh" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1uShnG-000fAn-NK; Fri, 20 Jun 2025 21:52:58 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector2; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From; bh=mAQn+LsaZ4KxkSKkcYxJ2lCZQrMV5oD1Rbyyax4M+T8=; b=bzkagKWhCKg6SwbYBr+HbsdL8H +hkdE7XiDraQ/p0S53rgS3RwqyMqwDvROukZ10+0sLHHLG61K5Pe6UjkcoZmQ7k+KtsC9iIuU3w+s sgtyDCckEa5NVvGHaG0sy1aBQ5fYJrzG9YVakBaW52XYJuITr9cV0HS3svwKh3Tv5+5UogsPHLWQD TXJd+aiOIoiZjstmKoEeYzx8mHH7PHB7HPYuQgFXDlIFzs2B5hdvP75tvjtEWfx7tRM5VQoOD/skn cQpmwG3ulgo7TNnfjQsJG/lbyOwZLPa3Hu2aC4RjYdZQB2RIiGw4p1itsnV48kIEIx2jMmEpsaHnL LGU84okw==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1uShnF-0003hD-PD; Fri, 20 Jun 2025 21:52:57 +0200 Received: by submission02.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1uShnE-00CRMQ-10; Fri, 20 Jun 2025 21:52:56 +0200 From: Michal Luczaj Date: Fri, 20 Jun 2025 21:52:45 +0200 Subject: [PATCH RFC net v2 3/3] vsock: Fix IOCTL_VM_SOCKETS_GET_LOCAL_CID to check also `transport_local` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250620-vsock-transports-toctou-v2-3-02ebd20b1d03@rbox.co> References: <20250620-vsock-transports-toctou-v2-0-02ebd20b1d03@rbox.co> In-Reply-To: <20250620-vsock-transports-toctou-v2-0-02ebd20b1d03@rbox.co> To: Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Stefan Hajnoczi Cc: virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Luczaj X-Mailer: b4 0.14.2 Support returning VMADDR_CID_LOCAL in case no other vsock transport is available. Fixes: 0e12190578d0 ("vsock: add local transport support in the vsock core") Suggested-by: Stefano Garzarella Signed-off-by: Michal Luczaj --- man vsock(7) mentions IOCTL_VM_SOCKETS_GET_LOCAL_CID vs. VMADDR_CID_LOCAL: Ioctls ... IOCTL_VM_SOCKETS_GET_LOCAL_CID ... Consider using VMADDR_CID_ANY when binding instead of getting the local CID with IOCTL_VM_SOCKETS_GET_LOCAL_CID. Local communication .... The local CID obtained with IOCTL_VM_SOCKETS_GET_LOCAL_CID can be used for the same purpose, but it is preferable to use VMADDR_CID_LOCAL. I was wondering it that would need some rewriting, since we're adding VMADDR_CID_LOCAL as a possible ioctl's return value. --- net/vmw_vsock/af_vsock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index a1b1073a2c89f865fcdb58b38d8e7feffcf1544f..4bdb4016bd14d790f3d217d5063= be64a1553b194 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -2577,6 +2577,8 @@ static long vsock_dev_do_ioctl(struct file *filp, cid =3D vsock_transport_local_cid(&transport_g2h); if (cid =3D=3D VMADDR_CID_ANY) cid =3D vsock_transport_local_cid(&transport_h2g); + if (cid =3D=3D VMADDR_CID_ANY && transport_local) + cid =3D VMADDR_CID_LOCAL; =20 if (put_user(cid, p) !=3D 0) retval =3D -EFAULT; --=20 2.49.0