Skip to content

Commit 8e48e58

Browse files
committed
vsock: Orphan socket after transport release
jira VULN-53603 cve CVE-2025-21756 commit-author Michal Luczaj <[email protected]> commit 78dafe1 upstream-diff Indentation is different from upstream change because this kernel lacks 135ffc7 ("bpf, vsock: Invoke proto::close on close()"). Otherwise the change content is the same. During socket release, sock_orphan() is called without considering that it sets sk->sk_wq to NULL. Later, if SO_LINGER is enabled, this leads to a null pointer dereferenced in virtio_transport_wait_close(). Orphan the socket only after transport release. Partially reverts the 'Fixes:' commit. KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] lock_acquire+0x19e/0x500 _raw_spin_lock_irqsave+0x47/0x70 add_wait_queue+0x46/0x230 virtio_transport_release+0x4e7/0x7f0 __vsock_release+0xfd/0x490 vsock_release+0x90/0x120 __sock_release+0xa3/0x250 sock_close+0x14/0x20 __fput+0x35e/0xa90 __x64_sys_close+0x78/0xd0 do_syscall_64+0x93/0x1b0 entry_SYSCALL_64_after_hwframe+0x76/0x7e Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=9d55b199192a4be7d02c Fixes: fcdd224 ("vsock: Keep the binding until socket destruction") Tested-by: Luigi Leonardi <[email protected]> Reviewed-by: Luigi Leonardi <[email protected]> Signed-off-by: Michal Luczaj <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit 78dafe1) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 7b6f4e6 commit 8e48e58

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,19 @@ static void __vsock_release(struct sock *sk, int level)
787787
*/
788788
lock_sock_nested(sk, level);
789789

790-
sock_orphan(sk);
790+
/* Indicate to vsock_remove_sock() that the socket is being released and
791+
* can be removed from the bound_table. Unlike transport reassignment
792+
* case, where the socket must remain bound despite vsock_remove_sock()
793+
* being called from the transport release() callback.
794+
*/
795+
sock_set_flag(sk, SOCK_DEAD);
791796

792797
if (vsk->transport)
793798
vsk->transport->release(vsk);
794799
else if (sk->sk_type == SOCK_STREAM)
795800
vsock_remove_sock(vsk);
796801

802+
sock_orphan(sk);
797803
sk->sk_shutdown = SHUTDOWN_MASK;
798804

799805
skb_queue_purge(&sk->sk_receive_queue);

0 commit comments

Comments
 (0)