OSDN Git Service

vsock/loopback: use only sk_buff_head.lock to protect the packet queue
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 24 Mar 2023 11:54:50 +0000 (12:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Mar 2023 07:14:39 +0000 (08:14 +0100)
commitb465518dc27da1ed74b8cbada4659708aac35adb
tree77a1650ead59c03dbd85e2056534664a617170c5
parent622035847f5e8661be7c0b9d6222391ccd8022bc
vsock/loopback: use only sk_buff_head.lock to protect the packet queue

pkt_list_lock was used before commit 71dc9ec9ac7d ("virtio/vsock:
replace virtio_vsock_pkt with sk_buff") to protect the packet queue.
After that commit we switched to sk_buff and we are using
sk_buff_head.lock in almost every place to protect the packet queue
except in vsock_loopback_work() when we call skb_queue_splice_init().

As reported by syzbot, this caused unlocked concurrent access to the
packet queue between vsock_loopback_work() and
vsock_loopback_cancel_pkt() since it is not holding pkt_list_lock.

With the introduction of sk_buff_head, pkt_list_lock is redundant and
can cause confusion, so let's remove it and use sk_buff_head.lock
everywhere to protect the packet queue access.

Fixes: 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff")
Cc: bobby.eshleman@bytedance.com
Reported-and-tested-by: syzbot+befff0a9536049e7902e@syzkaller.appspotmail.com
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
Reviewed-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/vsock_loopback.c