Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

virtio: set skb owner of virtio_transport_reset_no_sock() reply

Associate reply packets with the sending socket. When vsock must reply
with an RST packet and there exists a sending socket (e.g., for
loopback), setting the skb owner to the socket correctly handles
reference counting between the skb and sk (i.e., the sk stays alive
until the skb is freed).

This allows the net namespace to be used for socket lookups for the
duration of the reply skb's lifetime, preventing race conditions between
the namespace lifecycle and vsock socket search using the namespace
pointer.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260121-vsock-vmtest-v16-2-2859a7512097@meta.com
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Bobby Eshleman and committed by
Paolo Abeni
a6ae12a5 eafb64f4

+6
+6
net/vmw_vsock/virtio_transport_common.c
··· 1177 1177 .op = VIRTIO_VSOCK_OP_RST, 1178 1178 .type = le16_to_cpu(hdr->type), 1179 1179 .reply = true, 1180 + 1181 + /* Set sk owner to socket we are replying to (may be NULL for 1182 + * non-loopback). This keeps a reference to the sock and 1183 + * sock_net(sk) until the reply skb is freed. 1184 + */ 1185 + .vsk = vsock_sk(skb->sk), 1180 1186 }; 1181 1187 struct sk_buff *reply; 1182 1188