]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vsock: Do not allow binding to VMADDR_PORT_ANY
authorBudimir Markovic <markovicbudimir@gmail.com>
Thu, 7 Aug 2025 04:18:11 +0000 (04:18 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:05:11 +0000 (12:05 +0200)
commitf138be5d7f301fddad4e65ec66dfc3ceebf79be3
tree4bab5d791daff91611c6077963f76584a4bcd36a
parent7de07705007c7e34995a5599aaab1d23e762d7ca
vsock: Do not allow binding to VMADDR_PORT_ANY

commit aba0c94f61ec05315fa7815d21aefa4c87f6a9f4 upstream.

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 fcdd2242c023 (vsock: Keep
the binding until socket destruction).

Modify the check in __vsock_bind_connectible() to also prevent binding
to VMADDR_PORT_ANY.

Fixes: d021c344051a ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/vmw_vsock/af_vsock.c