net: Prevent infinite while loop in skb_tx_hash()
Subsystems (2)
PATCH 1/1 net: Prevent infinite while loop in skb_tx_hash()
Drivers call netdev_set_num_tc() and then netdev_set_tc_queue() to set the queue count and offset for each TC. So the queue count and offset for the TCs may be zero for a short period after dev->num_tc has been set. If a TX packet is being transmitted at this time in the code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see nonzero dev->num_tc but zero qcount for the TC. The while loop that keeps looping while hash >= qcount will not end.
Fix it by checking the TC's qcount to be nonzero before using it.
--- net/core/dev.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/dev.c +6 -0
@@ -3163,6 +3163,12 @@ static u16 skb_tx_hash(const struct net_device *dev, qoffset = sb_dev->tc_to_txq[tc].offset; qcount = sb_dev->tc_to_txq[tc].count; +if (unlikely (!qcount)) { +net_warn_ratelimited ("%s: invalid qcount, qoffset %u for tc %u\n" , + sb_dev->name, qoffset, tc); + qoffset =0 ; + qcount = dev->real_num_tx_queues; + } }if (skb_rx_queue_recorded (skb)) {
Signature · 1 line
2.18.1
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Mon, 25 Oct 2021 05:05:28 -0400 you wrote:
Drivers call
netdev_set_num_tc()and thennetdev_set_tc_queue()to set the queue count and offset for each TC. So the queue count and offset for the TCs may be zero for a short period afterdev->num_tchas been set. If a TX packet is being transmitted at this time in the code pathnetdev_pick_tx()->skb_tx_hash(),skb_tx_hash()may see nonzerodev->num_tcbut zero qcount for the TC. The while loop that keeps looping while hash >= qcount will not end.[...]
Here is the summary with links:
- [net] net: Prevent infinite while loop in skb_tx_hash()
https://git.kernel.org/netdev/net/c/0c57eeecc559
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html