]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vsock: Fix IOCTL_VM_SOCKETS_GET_LOCAL_CID to check also `transport_local`
authorMichal Luczaj <mhal@rbox.co>
Thu, 3 Jul 2025 15:18:20 +0000 (17:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:27:53 +0000 (18:27 +0200)
[ Upstream commit 1e7d9df379a04ccd0c2f82f39fbb69d482e864cc ]

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 <sgarzare@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250703-vsock-transports-toctou-v4-3-98f0eb530747@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/vmw_vsock/af_vsock.c

index f65868d2e82c3402a6baf47e1f2f9115834896c3..56bbc2970ffef0b6e76a078b2a1d551b23fa9d3a 100644 (file)
@@ -2186,6 +2186,8 @@ static long vsock_dev_do_ioctl(struct file *filp,
                cid = vsock_registered_transport_cid(&transport_g2h);
                if (cid == VMADDR_CID_ANY)
                        cid = vsock_registered_transport_cid(&transport_h2g);
+               if (cid == VMADDR_CID_ANY)
+                       cid = vsock_registered_transport_cid(&transport_local);
 
                if (put_user(cid, p) != 0)
                        retval = -EFAULT;