diff options
author | Mintz, Yuval <Yuval.Mintz@cavium.com> | 2016-10-29 10:04:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-10-29 20:51:46 -0400 |
commit | 087892d29b75c025086d99b29d385a3dac0169fc (patch) | |
tree | 89e4196468b2f6c5267d8c725651371b6a8948cc | |
parent | 3034783472f5353f71af44ed52ad9ee65f9f6d17 (diff) |
qede: Fix out-of-bound fastpath memory access
Driver allocates a shadow array for transmitted SKBs with X entries;
That means valid indices are {0,...,X - 1}. [X == 8191]
Problem is the driver also uses X as a mask for a
producer/consumer in order to choose the right entry in the
array which allows access to entry X which is out of bounds.
To fix this, simply allocate X + 1 entries in the shadow array.
Signed-off-by: Yuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/qlogic/qede/qede_main.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c index 444b271059b2..7def29aaf65c 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c | |||
@@ -2940,7 +2940,7 @@ static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq) | |||
2940 | txq->num_tx_buffers = edev->q_num_tx_buffers; | 2940 | txq->num_tx_buffers = edev->q_num_tx_buffers; |
2941 | 2941 | ||
2942 | /* Allocate the parallel driver ring for Tx buffers */ | 2942 | /* Allocate the parallel driver ring for Tx buffers */ |
2943 | size = sizeof(*txq->sw_tx_ring) * NUM_TX_BDS_MAX; | 2943 | size = sizeof(*txq->sw_tx_ring) * TX_RING_SIZE; |
2944 | txq->sw_tx_ring = kzalloc(size, GFP_KERNEL); | 2944 | txq->sw_tx_ring = kzalloc(size, GFP_KERNEL); |
2945 | if (!txq->sw_tx_ring) { | 2945 | if (!txq->sw_tx_ring) { |
2946 | DP_NOTICE(edev, "Tx buffers ring allocation failed\n"); | 2946 | DP_NOTICE(edev, "Tx buffers ring allocation failed\n"); |
@@ -2951,7 +2951,7 @@ static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq) | |||
2951 | QED_CHAIN_USE_TO_CONSUME_PRODUCE, | 2951 | QED_CHAIN_USE_TO_CONSUME_PRODUCE, |
2952 | QED_CHAIN_MODE_PBL, | 2952 | QED_CHAIN_MODE_PBL, |
2953 | QED_CHAIN_CNT_TYPE_U16, | 2953 | QED_CHAIN_CNT_TYPE_U16, |
2954 | NUM_TX_BDS_MAX, | 2954 | TX_RING_SIZE, |
2955 | sizeof(*p_virt), &txq->tx_pbl); | 2955 | sizeof(*p_virt), &txq->tx_pbl); |
2956 | if (rc) | 2956 | if (rc) |
2957 | goto err; | 2957 | goto err; |