Skip to content

Commit ed894f5

Browse files
Michael Changregkh
Michael Chan
authored andcommitted
net: Prevent infinite while loop in skb_tx_hash()
commit 0c57eee upstream. 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. Fixes: eadec87 ("net: Add support for subordinate traffic classes to netdev_pick_tx") Reviewed-by: Andy Gospodarek <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f435287 commit ed894f5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/core/dev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,6 +3246,12 @@ static u16 skb_tx_hash(const struct net_device *dev,
32463246

32473247
qoffset = sb_dev->tc_to_txq[tc].offset;
32483248
qcount = sb_dev->tc_to_txq[tc].count;
3249+
if (unlikely(!qcount)) {
3250+
net_warn_ratelimited("%s: invalid qcount, qoffset %u for tc %u\n",
3251+
sb_dev->name, qoffset, tc);
3252+
qoffset = 0;
3253+
qcount = dev->real_num_tx_queues;
3254+
}
32493255
}
32503256

32513257
if (skb_rx_queue_recorded(skb)) {

0 commit comments

Comments
 (0)