igb-linux: fix array size overrun
Subsystems (2)
PATCH v2 1/1 igb-linux: fix array size overrun
igb_configure_msix() and igb_setup_dca() functions use the value of q_vectors number without checking if it exceeds the MAX_Q_VECTORS limit. As these functions read values from an array, there is a chance it will case an undesired and undefined behavior. Other parts of the code do this check, issue a warning and alter their logic by using the MAX_Q_VECTORS value in such case.
Fix it by introducing num_q_vectors variable inside these functions which value depends on a check.
---
v2: Fixed the commit message
--- drivers/net/ethernet/intel/igb/igb.h | 2 +- drivers/net/ethernet/intel/igb/igb_main.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +1 -1
@@ -45,7 +45,7 @@ struct igb_adapter;#define IGB_MAX_ITR_USECS 10000#define IGB_MIN_ITR_USECS 10#define NON_Q_VECTORS 1 -#define MAX_Q_VECTORS 8 +#define MAX_Q_VECTORS 8U#define MAX_MSIX_ENTRIES 10/* Transmit and receive queues */
drivers/net/ethernet/intel/igb/igb_main.c +4 -2
@@ -865,6 +865,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)u32 tmp;int i, vector =0 ;struct e1000_hw *hw = &adapter->hw; +int num_q_vectors =min (MAX_Q_VECTORS , adapter->num_q_vectors); adapter->eims_enable_mask =0 ;
@@ -913,7 +914,7 @@ static void igb_configure_msix(struct igb_adapter *adapter) adapter->eims_enable_mask |= adapter->eims_other; -for (i =0 ; i < adapter->num_q_vectors; i++) +for (i =0 ; i < num_q_vectors; i++)igb_assign_vector (adapter->q_vector[i], vector++);wrfl ();
@@ -7149,6 +7150,7 @@ static void igb_setup_dca(struct igb_adapter *adapter) {struct e1000_hw *hw = &adapter->hw;int i; +int num_q_vectors =min (MAX_Q_VECTORS , adapter->num_q_vectors);if (!(adapter->flags &IGB_FLAG_DCA_ENABLED ))return ;
@@ -7156,7 +7158,7 @@ static void igb_setup_dca(struct igb_adapter *adapter)/* Always use CB2 mode, difference is masked in the CB driver. */ wr32 (E1000_DCA_CTRL ,E1000_DCA_CTRL_DCA_MODE_CB2 ); -for (i =0 ; i < adapter->num_q_vectors; i++) { +for (i =0 ; i < num_q_vectors; i++) { adapter->q_vector[i]->cpu =-1 ;igb_update_dca (adapter->q_vector[i]); }
Signature · 6 lines
2.25.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainers/igb-linux/igb
Quoted 36 lines · Andrii Staikov
igb_configure_msix()andigb_setup_dca()functions use the value ofq_vectorsnumber without checking if it exceeds theMAX_Q_VECTORSlimit. As these functions read values from an array, there is a chance it will case an undesired and undefined behavior. Other parts of the code do this check, issue a warning and alter their logic by using theMAX_Q_VECTORSvalue in such case.
Fix it by introducingnum_q_vectorsvariable inside these functions which value depends on a check.Fixes 9d5c824399de ("igb: PCI-Express 82575 Gigabit Ethernet driver")Signed-off-by Andrii Staikov <[email protected]>---
v2: Fixed the commit message--- drivers/net/ethernet/intel/igb/igb.h | 2 +- drivers/net/ethernet/intel/igb/igb_main.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/igb/igb.h +1
-1@@ -45,7 +45,7 @@ struct igb_adapter;#define IGB_MAX_ITR_USECS 10000#define IGB_MIN_ITR_USECS 10#define NON_Q_VECTORS 1 -#define MAX_Q_VECTORS 8 +#define MAX_Q_VECTORS 8U#define MAX_MSIX_ENTRIES 10/* Transmit and receive queues */ drivers/net/ethernet/intel/igb/igb_main.c +0
-0
drivers/net/ethernet/intel/igb/igb_main.c static void igb_configure_msix(struct igb_adapter *adapter) · line 868
Quoted 4 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-0@@ -865,6 +865,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)u32 tmp;int i, vector =0 ;struct e1000_hw *hw = &adapter->hw; +int num_q_vectors =min (MAX_Q_VECTORS , adapter->num_q_vectors);
RCT please
Quoted 12 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-1adapter->eims_enable_mask =0 ;@@ -913,7 +914,7 @@ static void igb_configure_msix(struct igb_adapter *adapter) adapter->eims_enable_mask |= adapter->eims_other; -for (i =0 ; i < adapter->num_q_vectors; i++) +for (i =0 ; i < num_q_vectors; i++)igb_assign_vector (adapter->q_vector[i], vector++);wrfl ();
drivers/net/ethernet/intel/igb/igb_main.c static void igb_setup_dca(struct igb_adapter *adapter) · line 7153
Quoted 4 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-0@@ -7149,6 +7150,7 @@ static void igb_setup_dca(struct igb_adapter *adapter) {struct e1000_hw *hw = &adapter->hw;int i; +int num_q_vectors =min (MAX_Q_VECTORS , adapter->num_q_vectors);
Here as well
drivers/net/ethernet/intel/igb/igb_main.c static void igb_setup_dca(struct igb_adapter *adapter) · line 7164
Quoted 11 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-1if (!(adapter->flags &IGB_FLAG_DCA_ENABLED ))return ;@@ -7156,7 +7158,7 @@ static void igb_setup_dca(struct igb_adapter *adapter)/* Always use CB2 mode, difference is masked in the CB driver. */ wr32 (E1000_DCA_CTRL ,E1000_DCA_CTRL_DCA_MODE_CB2 ); -for (i =0 ; i < adapter->num_q_vectors; i++) { +for (i =0 ; i < num_q_vectors; i++) { adapter->q_vector[i]->cpu =-1 ;igb_update_dca (adapter->q_vector[i]); }
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan