Skip to content

Commit 1cc6571

Browse files
Nick Childkuba-moo
authored andcommitted
netdev: Enforce index cap in netdev_get_tx_queue
When requesting a TX queue at a given index, warn on out-of-bounds referencing if the index is greater than the allocated number of queues. Specifically, since this function is used heavily in the networking stack use DEBUG_NET_WARN_ON_ONCE to avoid executing a new branch on every packet. Signed-off-by: Nick Child <nnac123@linux.ibm.com> Link: https://lore.kernel.org/r/20230321150725.127229-2-nnac123@linux.ibm.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5dd0dfd commit 1cc6571

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,7 @@ static inline
24842484
struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
24852485
unsigned int index)
24862486
{
2487+
DEBUG_NET_WARN_ON_ONCE(index >= dev->num_tx_queues);
24872488
return &dev->_tx[index];
24882489
}
24892490

0 commit comments

Comments
 (0)