mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
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 infcdd2242c0
(vsock: Keep the binding until socket destruction). Modify the check in __vsock_bind_connectible() to also prevent binding to VMADDR_PORT_ANY. Fixes:d021c34405
("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>
This commit is contained in:
parent
f1791fd7b8
commit
d73960f0cf
|
@ -689,7 +689,8 @@ static int __vsock_bind_connectible(struct vsock_sock *vsk,
|
|||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_PORT_RETRIES; i++) {
|
||||
if (port <= LAST_RESERVED_PORT)
|
||||
if (port == VMADDR_PORT_ANY ||
|
||||
port <= LAST_RESERVED_PORT)
|
||||
port = LAST_RESERVED_PORT + 1;
|
||||
|
||||
new_addr.svm_port = port++;
|
||||
|
|
Loading…
Reference in New Issue
Block a user