diff options
| author | Nick Child <nnac123@linux.ibm.com> | 2023-03-21 18:07:25 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-24 19:32:37 +0300 |
| commit | d957a100bcc2e0ea6b770781a849ba7c3efe1532 (patch) | |
| tree | b2d7a873560e611f35b6527afd93dd48cb6ed245 /include/linux/netdevice.h | |
| parent | cf1fe8ccb5060b60be0ebaa1f861e9ea46101eae (diff) | |
| download | linux-d957a100bcc2e0ea6b770781a849ba7c3efe1532.tar.xz | |
netdev: Enforce index cap in netdev_get_tx_queue
[ Upstream commit 1cc6571f562774f1d928dc8b3cff50829b86e970 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b072449b0f1a..eac51e22a52a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2428,6 +2428,7 @@ static inline struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, unsigned int index) { + DEBUG_NET_WARN_ON_ONCE(index >= dev->num_tx_queues); return &dev->_tx[index]; } |
