All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access.
@ 2021-04-16 16:59 Aleksandr Loktionov
  2021-04-20 20:15 ` Nguyen, Anthony L
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandr Loktionov @ 2021-04-16 16:59 UTC (permalink / raw)
  To: intel-wired-lan

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.

Fixes: 047e0030f1e6 ("igb: add new data structure for handling
interrupts and NAPI")
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Slawomir Laba <slawomirx.laba@intel.com>
Reviewed-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Verified-by: Mateusz Palczewski <mateusz.placzewski@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 55051a492..2c601261f 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -929,6 +929,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)
  **/
 static int igb_request_msix(struct igb_adapter *adapter)
 {
+	unsigned int num_q_vectors = adapter->num_q_vectors;
 	struct net_device *netdev = adapter->netdev;
 	int i, err = 0, vector = 0, free_vector = 0;
 
@@ -937,7 +938,13 @@ static int igb_request_msix(struct igb_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 igb_q_vector *q_vector = adapter->q_vector[i];
 
 		vector++;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access.
  2021-04-16 16:59 [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access Aleksandr Loktionov
@ 2021-04-20 20:15 ` Nguyen, Anthony L
  0 siblings, 0 replies; 4+ messages in thread
From: Nguyen, Anthony L @ 2021-04-20 20:15 UTC (permalink / raw)
  To: intel-wired-lan

On Fri, 2021-04-16 at 16:59 +0000, Aleksandr Loktionov wrote:
> 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.
> 
> Fixes: 047e0030f1e6 ("igb: add new data structure for handling
> interrupts and NAPI")

The Fixes tag should not be wrapped. It's exempt from the 75 char
limit.

> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
> Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> Reviewed-by: Slawomir Laba <slawomirx.laba@intel.com>
> Reviewed-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
> Verified-by: Mateusz Palczewski <mateusz.placzewski@intel.com>

WARNING: Non-standard signature: Verified-by:

Please fix and resend.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access.
  2021-04-21 15:15 Aleksandr Loktionov
@ 2021-04-21 23:04 ` Nguyen, Anthony L
  0 siblings, 0 replies; 4+ messages in thread
From: Nguyen, Anthony L @ 2021-04-21 23:04 UTC (permalink / raw)
  To: intel-wired-lan

On Wed, 2021-04-21 at 15:15 +0000, Aleksandr Loktionov wrote:
> 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.
> 
> Fixes: 047e0030f1e6 ("igb: add new data structure for handling
> interrupts and NAPI")

As I mentioned in the last version, don't wrap the Fixes tag. It can go
over 75 char.

	Fixes tag: Fixes: 047e0030f1e6 ("igb: add new data structure
for handling
		Has these problem(s):
			- Subject has leading but no trailing 	parentheses
			- Subject has leading but no trailing quotes

Also, please remember to indicate revisions with change log when
resending. i.e. this should've been 'v2'. Can you fix the above and
resend as v3?

> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
> Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> Reviewed-by: Slawomir Laba <slawomirx.laba@intel.com>
> Reviewed-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
> Reviewed-by: Mateusz Palczewski <mateusz.placzewski@intel.com>
> ---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access.
@ 2021-04-21 15:15 Aleksandr Loktionov
  2021-04-21 23:04 ` Nguyen, Anthony L
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandr Loktionov @ 2021-04-21 15:15 UTC (permalink / raw)
  To: intel-wired-lan

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.

Fixes: 047e0030f1e6 ("igb: add new data structure for handling
interrupts and NAPI")
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Slawomir Laba <slawomirx.laba@intel.com>
Reviewed-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Reviewed-by: Mateusz Palczewski <mateusz.placzewski@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 55051a492..2c601261f 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -929,6 +929,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)
  **/
 static int igb_request_msix(struct igb_adapter *adapter)
 {
+	unsigned int num_q_vectors = adapter->num_q_vectors;
 	struct net_device *netdev = adapter->netdev;
 	int i, err = 0, vector = 0, free_vector = 0;
 
@@ -937,7 +938,13 @@ static int igb_request_msix(struct igb_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 igb_q_vector *q_vector = adapter->q_vector[i];
 
 		vector++;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-21 23:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 16:59 [Intel-wired-lan] [net] igb: Check if num of q_vectors is smaller than max before array access Aleksandr Loktionov
2021-04-20 20:15 ` Nguyen, Anthony L
2021-04-21 15:15 Aleksandr Loktionov
2021-04-21 23:04 ` Nguyen, Anthony L

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.