Skip to content

Commit 0c57eee

Browse files
Michael Chandavem330
authored andcommitted
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. 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]>
1 parent ace19b9 commit 0c57eee

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
@@ -3163,6 +3163,12 @@ static u16 skb_tx_hash(const struct net_device *dev,
31633163

31643164
qoffset = sb_dev->tc_to_txq[tc].offset;
31653165
qcount = sb_dev->tc_to_txq[tc].count;
3166+
if (unlikely(!qcount)) {
3167+
net_warn_ratelimited("%s: invalid qcount, qoffset %u for tc %u\n",
3168+
sb_dev->name, qoffset, tc);
3169+
qoffset = 0;
3170+
qcount = dev->real_num_tx_queues;
3171+
}
31663172
}
31673173

31683174
if (skb_rx_queue_recorded(skb)) {

0 commit comments

Comments
 (0)