Skip to content

Commit 381ee88

Browse files
markovicbudimirsmb49
authored andcommitted
vsock: Do not allow binding to VMADDR_PORT_ANY
It is possible for a vsock to autobind to VMADDR_PORT_ANY. This can cause a use-after-free when a connection is made to the bound socket. The socket returned by accept() also has port VMADDR_PORT_ANY but is not on the list of unbound sockets. Binding it will result in an extra refcount decrement similar to the one fixed in fcdd224 (vsock: Keep the binding until socket destruction). Modify the check in __vsock_bind_connectible() to also prevent binding to VMADDR_PORT_ANY. Fixes: d021c34 ("VSOCK: Introduce VM Sockets") Reported-by: Budimir Markovic<markovicbudimir@gmail.com> Signed-off-by: Budimir Markovic<markovicbudimir@gmail.com> Reviewed-by: Stefano Garzarella<sgarzare@redhat.com> Link:https://patch.msgid.link/20250807041811.678-1-markovicbudimir@gmail.com Signed-off-by: Jakub Kicinski<kuba@kernel.org> CVE-2025-38618 (cherry picked from commit aba0c94f61ec05315fa7815d21aefa4c87f6a9f4) Signed-off-by: Ian Whitfield<ian.whitfield@canonical.com> Acked-by: Bethany Jamison <bethany.jamison@canonical.com> Acked-by: Stefan Bader <stefan.bader@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8438f04 commit 381ee88

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ static int __vsock_bind_connectible(struct vsock_sock *vsk,
655655
unsigned int i;
656656

657657
for (i = 0; i < MAX_PORT_RETRIES; i++) {
658-
if (port <= LAST_RESERVED_PORT)
658+
if (port == VMADDR_PORT_ANY ||
659+
port <= LAST_RESERVED_PORT)
659660
port = LAST_RESERVED_PORT + 1;
660661

661662
new_addr.svm_port = port++;

0 commit comments

Comments
 (0)