igc: Check if num of q_vectors is smaller than max before array access
Subsystems (2)
PATCH 1/1 igc: Check if num of q_vectors is smaller than max before array access
Ensure that the adapter->q_vector[MAX_Q_VECTORS] array isn't accessed beyond its size. It was fixed by using a local variable num_q_vectors as a limit for loop index, and ensure that num_q_vectors is not bigger than MAX_Q_VECTORS.
Suggested-by Aleksandr Loktionov <[email protected]>
Signed-off-by Sasha Neftin <[email protected]>
--- drivers/net/ethernet/intel/igc/igc_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +8 -1
@@ -4817,6 +4817,7 @@ static irqreturn_t igc_msix_ring(int irq, void *data)*/ static int igc_request_msix (struct igc_adapter *adapter) { +unsigned int num_q_vectors = adapter->num_q_vectors;int i =0 , err =0 , vector =0 , free_vector =0 ;struct net_device *netdev = adapter->netdev;
@@ -4825,7 +4826,13 @@ static int igc_request_msix(struct igc_adapter *adapter)if (err) goto err_out; -for (i =0 ; i < adapter->num_q_vectors; i++) { +if (num_q_vectors >MAX_Q_VECTORS ) { + num_q_vectors =MAX_Q_VECTORS ; +dev_warn (&adapter->pdev->dev, +"The number of queue vectors (%d) is higher than max allowed (%d)\n" , + adapter->num_q_vectors,MAX_Q_VECTORS ); + } +for (i =0 ; i < num_q_vectors; i++) {struct igc_q_vector *q_vector = adapter->q_vector[i]; vector++;
Signature · 1 line
2.25.1
Fuxbrumer
PATCH 1/1 igc: Check if num of q_vectors is smaller than max before array access
Quoted 11 lines · Sasha Neftin
Ensure that the adapter->q_vector[MAX_Q_VECTORS] array isn't accessed beyond its size. It was fixed by using a local variable
num_q_vectorsas a limit for loop index, and ensure thatnum_q_vectorsis not bigger thanMAX_Q_VECTORS.Suggested-by Aleksandr Loktionov <[email protected]>Signed-off-by Sasha Neftin <[email protected]>--- drivers/net/ethernet/intel/igc/igc_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Tested-by Dvora Fuxbrumer <[email protected]>