Skip to content

Commit 82ffbe7

Browse files
edumazetkuba-moo
authored andcommitted
net_sched: sch_sfq: fix a potential crash on gso_skb handling
SFQ has an assumption of always being able to queue at least one packet. However, after the blamed commit, sch->q.len can be inflated by packets in sch->gso_skb, and an enqueue() on an empty SFQ qdisc can be followed by an immediate drop. Fix sfq_drop() to properly clear q->tail in this situation. Tested: ip netns add lb ip link add dev to-lb type veth peer name in-lb netns lb ethtool -K to-lb tso off # force qdisc to requeue gso_skb ip netns exec lb ethtool -K in-lb gro on # enable NAPI ip link set dev to-lb up ip -netns lb link set dev in-lb up ip addr add dev to-lb 192.168.20.1/24 ip -netns lb addr add dev in-lb 192.168.20.2/24 tc qdisc replace dev to-lb root sfq limit 100 ip netns exec lb netserver netperf -H 192.168.20.2 -l 100 & netperf -H 192.168.20.2 -l 100 & netperf -H 192.168.20.2 -l 100 & netperf -H 192.168.20.2 -l 100 & Fixes: a53851e ("net: sched: explicit locking in gso_cpu fallback") Reported-by: Marcus Wichelmann <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Toke Høiland-Jørgensen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 82cbd06 commit 82ffbe7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/sched/sch_sfq.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)
310310
/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
311311
x = q->tail->next;
312312
slot = &q->slots[x];
313-
q->tail->next = slot->next;
313+
if (slot->next == x)
314+
q->tail = NULL; /* no more active slots */
315+
else
316+
q->tail->next = slot->next;
314317
q->ht[slot->hash] = SFQ_EMPTY_SLOT;
315318
goto drop;
316319
}

0 commit comments

Comments
 (0)