Blob Blame History Raw
From: Jiri Kosina <jkosina@suse.cz>
Date: Sat, 03 Apr 2021 15:00:00 +0200
Subject: [PATCH] net: sched: disable TCQ_F_NOLOCK for pfifo_fast
Patch-mainline: never, proper fix in progress
References: bsc#1183405

The patch disables NOLOCK functionality for pfifo_fast and thus closes the following
race condition:

- thread A holds seqlock on the qdisc and has finished processing / dequeuing packets
  (has dequeued last packet)
- thread A iterates through the qdisc->dequeue() pfifo_fast's callback again and
  determines that the queue is indeed empty
- thread B enqueues a packet. Since seqlock is still being held by thread A, it
  assumes the packet will eventually be dequeued by the current lock holder
- thread A unlocks seqlock
- there is nobody to check for enqueued packets, until new packet is enqueued

Fixes: c5ad119fb6c0 ("net: sched: pfifo_fast use skb_array")
Fixes: 6b3ba9146fe6 ("net: sched: allow qdiscs to handle locking")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

--- 

--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -806,7 +806,7 @@
 	.dump		=	pfifo_fast_dump,
 	.change_tx_queue_len =  pfifo_fast_change_tx_queue_len,
 	.owner		=	THIS_MODULE,
-	.static_flags	=	TCQ_F_NOLOCK | TCQ_F_CPUSTATS,
+	.static_flags	=	TCQ_F_CPUSTATS,
 };
 EXPORT_SYMBOL(pfifo_fast_ops);