net_sched: sch_sfq: fix a potential crash on gso_skb handling
Subsystems (3)
PATCH 1/1 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 &
--- net/sched/sch_sfq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/sched/sch_sfq.c +4 -1
@@ -310,7 +310,10 @@ static unsigned int sfq_drop(struct Qdisc *sch, struct sk_buff **to_free)/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ x = q->tail->next; slot = &q->slots[x]; - q->tail->next = slot->next; +if (slot->next == x) + q->tail =NULL ;/* no more active slots */ +else + q->tail->next = slot->next; q->ht[slot->hash] =SFQ_EMPTY_SLOT ; goto drop; }
Signature · 1 line
2.50.0.rc0.604.gd4ff7b7c86-goog
Quoted 27 lines · Eric Dumazet
SFQ has an assumption of always being able to queue at least one packet.
However, after the blamed commit,
sch->q.lencan be inflated by packets insch->gso_skb, and anenqueue()on an empty SFQ qdisc can be followed by an immediate drop.Fix
sfq_drop()to properly clearq->tailin 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 requeuegso_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 100ip 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 &
Quoted 4 lines
Fixes a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback")Reported-by Marcus Wichelmann <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Thanks for the quick fix!
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 6 Jun 2025 16:51:27 +0000 you wrote:
SFQ has an assumption of always being able to queue at least one packet.
However, after the blamed commit,
sch->q.lencan be inflated by packets insch->gso_skb, and anenqueue()on an empty SFQ qdisc can be followed by an immediate drop.Fix
sfq_drop()to properly clearq->tailin this situation.[...]
Here is the summary with links:
- [net] net_sched: sch_sfq: fix a potential crash on gso_skb handling
https://git.kernel.org/netdev/net/c/82ffbe7776d0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html