Skip to contentSkip to conversation

i40e: fix MMIO write access to an invalid page in i40e_clear_hw

PATCH In review Kyungwook Boo 5 participants 6 messages Mar 11, 2025 – Mar 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i40e: fix MMIO write access to an invalid page in i40e_clear_hw

When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.

Prevent the integer underflow by changing the type of related variables.

---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -3
index 370b4bddee44..b11c35e307ca 100644
@@ -817,10 +817,11 @@ int i40e_pf_reset(struct i40e_hw *hw)
 void i40e_clear_hw(struct i40e_hw *hw)
 {
 	u32 num_queues, base_queue;
-	u32 num_pf_int;
-	u32 num_vf_int;
+	s32 num_pf_int;
+	s32 num_vf_int;
 	u32 num_vfs;
-	u32 i, j;
+	s32 i;
+	u32 j;
 	u32 val;
 	u32 eol = 0x7ff;
 

---
base-commit: 4d872d51bc9d7b899c1f61534e3dbde72613f627

Best regards,
Kyungwook Boo

maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 24 lines · Kyungwook Boo

When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.

Prevent the integer underflow by changing the type of related variables.

---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1: https://lore.kernel.org/netdev/[email protected]/

---
  drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +0 -0
index 370b4bddee44..b11c35e307ca 100644
@@ -817,10 +817,11 @@ int i40e_pf_reset(struct i40e_hw *hw)
  void i40e_clear_hw(struct i40e_hw *hw)
  {
  	u32 num_queues, base_queue;

drivers/net/ethernet/intel/i40e/i40e_common.c int i40e_pf_reset(struct i40e_hw *hw) · line 826

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -3
-	u32 num_pf_int;
-	u32 num_vf_int;
+	s32 num_pf_int;
+	s32 num_vf_int;
  	u32 num_vfs;
-	u32 i, j;
+	s32 i;
+	u32 j;
  	u32 val;
  	u32 eol = 0x7ff;

thank you for localizing the improvement, now the code is more robust,

Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +0 -1
---

base-commit: 4d872d51bc9d7b899c1f61534e3dbde72613f627

Best regards,
Kyungwook Boo

reviewer Reviewed-by on v2 1/1
#3 lore raw
In reply to Kyungwook Boo
Quoted 36 lines · Kyungwook Boo

When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.

Prevent the integer underflow by changing the type of related variables.

---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1: https://lore.kernel.org/netdev/[email protected]/

---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -4
index 370b4bddee44..b11c35e307ca 100644
@@ -817,10 +817,11 @@ int i40e_pf_reset(struct i40e_hw *hw)
 void i40e_clear_hw(struct i40e_hw *hw)
 {
 	u32 num_queues, base_queue;
-	u32 num_pf_int;
-	u32 num_vf_int;
+	s32 num_pf_int;
+	s32 num_vf_int;
 	u32 num_vfs;
-	u32 i, j;
+	s32 i;
+	u32 j;
 	u32 val;
 	u32 eol = 0x7ff;
 
---
Quoted 1 line

base-commit: 4d872d51bc9d7b899c1f61534e3dbde72613f627

I see that this addresses the problem at the first link above. And I'd happy to see it accepted as-is.

But, as an aside, wouldn't it be more appropriate to use generic types like int and unsigned int for most of the above variables? Perhaps this could be addressed by a follow-up. Or perhaps that would just be churn, IDK.

#2 lore raw
In reply to Przemek Kitszel
Quoted 56 lines

-----Original Message-----
From: Kitszel, Przemyslaw <[email protected]>
Sent: Tuesday, March 11, 2025 10:15 AM
To: Kyungwook Boo <[email protected]>
Cc: [email protected]; [email protected]; Loktionov, Aleksandr <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: Re: [PATCH iwl-next v2] i40e: fix MMIO write access to an invalid page in i40e_clear_hw

Quoted 8 lines · Kyungwook Boo

When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.

Prevent the integer underflow by changing the type of related variables.

Link:
https://lore.kernel.org/lkml/ffc91764-1142-4ba2-91b6-

8c773f6f7095@gmai

Quoted 7 lines

l.com/T/
---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1:
https://lore.kernel.org/netdev/55acc5dc-8d5a-45bc-a59c-

9304071e4579@gm

Quoted 14 lines

ail.com/

---
  drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +0 -0
index 370b4bddee44..b11c35e307ca 100644
@@ -817,10 +817,11 @@ int i40e_pf_reset(struct i40e_hw *hw)
  void i40e_clear_hw(struct i40e_hw *hw)
  {
  	u32 num_queues, base_queue;

drivers/net/ethernet/intel/i40e/i40e_common.c int i40e_pf_reset(struct i40e_hw *hw) · line 826

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -3
-	u32 num_pf_int;
-	u32 num_vf_int;
+	s32 num_pf_int;
+	s32 num_vf_int;
  	u32 num_vfs;
-	u32 i, j;
+	s32 i;
+	u32 j;
  	u32 val;
  	u32 eol = 0x7ff;

thank you for localizing the improvement, now the code is more robust,

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_common.c +0 -1
---

base-commit: 4d872d51bc9d7b899c1f61534e3dbde72613f627

Best regards,
Kyungwook Boo

Tested-by on v2 1/1
#4 lore raw
In reply to Kyungwook Boo
Quoted 4 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kyungwook Boo
Sent: 11 March 2025 10:46
To: Loktionov, Aleksandr <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>

Quoted 8 lines

Subject: [Intel-wired-lan] [PATCH iwl-next v2] i40e: fix MMIO write access to an invalid page in i40e_clear_hw

When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.

Prevent the integer underflow by changing the type of related variables.

Quoted 9 lines

---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1: https://lore.kernel.org/netdev/[email protected]/
---
drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)
#5 lore raw
Quoted 24 lines

-----Original Message-----
From: Rinitha, SX <[email protected]>
Sent: Friday, March 21, 2025 5:47 AM
To: Kyungwook Boo <[email protected]>; Loktionov, Aleksandr <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [Intel-wired-lan] [PATCH iwl-next v2] i40e: fix MMIO write access to an invalid page in i40e_clear_hw

Quoted 2 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of

Kyungwook Boo

Quoted 2 lines

Sent: 11 March 2025 10:46
To: Loktionov, Aleksandr <[email protected]>; Kitszel,

Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>
Cc: [email protected]; [email protected]

Quoted 1 line

Subject: [Intel-wired-lan] [PATCH iwl-next v2] i40e: fix MMIO write access to

an invalid page in i40e_clear_hw

Quoted 1 line
Quoted 8 lines
Quoted 1 line

When the device sends a specific input, an integer underflow can occur,

leading to MMIO write access to an invalid page.

Quoted 5 lines

Prevent the integer underflow by changing the type of related variables.

[email protected]/T/

Quoted 12 lines
Quoted 5 lines

---
Changes in v2:
- Formatting properly
- Fix variable shadowing
- Link to v1: https://lore.kernel.org/netdev/55acc5dc-8d5a-45bc-a59c-

[email protected]/

Quoted 4 lines

---
drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)