Patch "vsock/loopback: use only sk_buff_head.lock to protect the packet queue" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vsock/loopback: use only sk_buff_head.lock to protect the packet queue

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vsock-loopback-use-only-sk_buff_head.lock-to-protect-the-packet-queue.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From b465518dc27da1ed74b8cbada4659708aac35adb Mon Sep 17 00:00:00 2001
From: Stefano Garzarella <sgarzare@xxxxxxxxxx>
Date: Fri, 24 Mar 2023 12:54:50 +0100
Subject: vsock/loopback: use only sk_buff_head.lock to protect the packet queue

From: Stefano Garzarella <sgarzare@xxxxxxxxxx>

commit b465518dc27da1ed74b8cbada4659708aac35adb upstream.

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@xxxxxxxxxxxxx
Reported-and-tested-by: syzbot+befff0a9536049e7902e@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
Reviewed-by: Bobby Eshleman <bobby.eshleman@xxxxxxxxxxxxx>
Reviewed-by: Arseniy Krasnov <AVKrasnov@xxxxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 net/vmw_vsock/vsock_loopback.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

--- a/net/vmw_vsock/vsock_loopback.c
+++ b/net/vmw_vsock/vsock_loopback.c
@@ -15,7 +15,6 @@
 struct vsock_loopback {
 	struct workqueue_struct *workqueue;
 
-	spinlock_t pkt_list_lock; /* protects pkt_list */
 	struct sk_buff_head pkt_queue;
 	struct work_struct pkt_work;
 };
@@ -32,9 +31,7 @@ static int vsock_loopback_send_pkt(struc
 	struct vsock_loopback *vsock = &the_vsock_loopback;
 	int len = skb->len;
 
-	spin_lock_bh(&vsock->pkt_list_lock);
 	skb_queue_tail(&vsock->pkt_queue, skb);
-	spin_unlock_bh(&vsock->pkt_list_lock);
 
 	queue_work(vsock->workqueue, &vsock->pkt_work);
 
@@ -113,9 +110,9 @@ static void vsock_loopback_work(struct w
 
 	skb_queue_head_init(&pkts);
 
-	spin_lock_bh(&vsock->pkt_list_lock);
+	spin_lock_bh(&vsock->pkt_queue.lock);
 	skb_queue_splice_init(&vsock->pkt_queue, &pkts);
-	spin_unlock_bh(&vsock->pkt_list_lock);
+	spin_unlock_bh(&vsock->pkt_queue.lock);
 
 	while ((skb = __skb_dequeue(&pkts))) {
 		virtio_transport_deliver_tap_pkt(skb);
@@ -132,7 +129,6 @@ static int __init vsock_loopback_init(vo
 	if (!vsock->workqueue)
 		return -ENOMEM;
 
-	spin_lock_init(&vsock->pkt_list_lock);
 	skb_queue_head_init(&vsock->pkt_queue);
 	INIT_WORK(&vsock->pkt_work, vsock_loopback_work);
 
@@ -156,9 +152,7 @@ static void __exit vsock_loopback_exit(v
 
 	flush_work(&vsock->pkt_work);
 
-	spin_lock_bh(&vsock->pkt_list_lock);
 	virtio_vsock_skb_queue_purge(&vsock->pkt_queue);
-	spin_unlock_bh(&vsock->pkt_list_lock);
 
 	destroy_workqueue(vsock->workqueue);
 }


Patches currently in stable-queue which might be from sgarzare@xxxxxxxxxx are

queue-6.1/virtio-vsock-fix-header-length-on-skb-merging.patch
queue-6.1/virtio-vsock-fix-leaks-due-to-missing-skb-owner.patch
queue-6.1/virtio-vsock-don-t-drop-skbuff-on-copy-failure.patch
queue-6.1/virtio-vsock-replace-virtio_vsock_pkt-with-sk_buff.patch
queue-6.1/virtio-vsock-don-t-use-skbuff-state-to-account-credit.patch
queue-6.1/virtio-vsock-remove-redundant-skb_pull-call.patch
queue-6.1/vsock-loopback-use-only-sk_buff_head.lock-to-protect-the-packet-queue.patch
queue-6.1/vsock-virtio-remove-socket-from-connected-bound-list.patch
queue-6.1/virtio-vsock-fix-uninit-value-in-virtio_transport_recv_pkt.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux