Skip to contentSkip to conversation

e1000e: Fix possible overflow in LTR decoding

PATCH New Sasha Neftin 6 participants 7 messages Apr 5, 2022 – Apr 11, 2022

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

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

When we decode the latency and the max_latency u16 value does not fill the required size and could lead to the wrong LTR representation. Replace the u16 type with the u32 type and allow corrected LTR representation.

Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for 10M")

---
v2: added link tag

 drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +2 -2
index d60e2016d03c..e6c8e6d5234f 100644
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
 {
 	u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
 	    link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
-	u16 max_ltr_enc_d = 0;	/* maximum LTR decoded by platform */
-	u16 lat_enc_d = 0;	/* latency decoded */
+	u32 max_ltr_enc_d = 0;	/* maximum LTR decoded by platform */
+	u32 lat_enc_d = 0;	/* latency decoded */
 	u16 lat_enc = 0;	/* latency encoded */
 
 	if (link) {
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

Quoted 10 lines · Sasha Neftin

When we decode the latency and the max_latency u16 value does not fill the required size and could lead to the wrong LTR representation. Replace the u16 type with the u32 type and allow corrected LTR representation.

Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for 10M")
Quoted 5 lines

---
v2: added link tag

  drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
#2 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

In reply to Sasha Neftin

Dear Sasha,

Thank you for your patch.

Am 05.04.22 um 17:56 schrieb Sasha Neftin:

Quoted 2 lines

When we decode the latency and the max_latency u16 value does not fill the required size

Do you mean ?fit into? or ?is too small for the required size??

Quoted 1 line

and could lead to the wrong LTR representation.

Maybe give an example of values leading to incorrect behavior?

Quoted 2 lines

Replace the u16 type with the u32 type and allow corrected LTR representation.

Maybe: Increase the variable size from u16 to u32, so the decoded latency can be represented. Why are 32 bit enough? Why not 64 bit?

Please use 75 characters per line.

Quoted 5 lines
Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for 10M")

Add

30))

Quoted 11 lines

---
v2: added link tag

  drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index d60e2016d03c..e6c8e6d5234f 100644

drivers/net/ethernet/intel/e1000e/ich8lan.c static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link) · line 1016

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/ich8lan.c +2 -2
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
  {
  	u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
  	    link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
-	u16 max_ltr_enc_d = 0;	/* maximum LTR decoded by platform */
-	u16 lat_enc_d = 0;	/* latency decoded */
+	u32 max_ltr_enc_d = 0;	/* maximum LTR decoded by platform */
+	u32 lat_enc_d = 0;	/* latency decoded */
  	u16 lat_enc = 0;	/* latency encoded */
 
  	if (link) {

The diff looks good.

Kind regards,

Paul

#3 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

Quoted 13 lines · Paul Menzel

Dear Sasha,

Thank you for your patch.

Am 05.04.22 um 17:56 schrieb Sasha Neftin:

Quoted 2 lines

When we decode the latency and the max_latency u16 value does not fill the required size

Do you mean ?fit into? or ?is too small for the required size??

Quoted 1 line

and could lead to the wrong LTR representation.

Quoted 7 lines

Maybe give an example of values leading to incorrect behavior?

Quoted 2 lines

Replace the u16 type with the u32 type and allow corrected LTR representation.

Maybe: Increase the variable size from u16 to u32, so the decoded latency can be represented. Why are 32 bit enough? Why not 64 bit?

Hello Paul,
Scaling represented as:

scale 0 - 1         (2^(5*0)) = 2^0
scale 1 - 32        (2^(5 *1))= 2^5
scale 2 - 1024      (2^(5 *2)) =2^10
scale 3 - 32768     (2^(5 *3)) =2^15
scale 4 ? 1048576   (2^(5 *4)) = 2^20
scale 5 ? 33554432  (2^(5 *4)) = 2^25

scale 4 and scale 5 required 20 and 25 bits respectively. scale 6 reserved.

Quoted 10 lines

Please use 75 characters per line.

Quoted 6 lines
Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for

10M")

Quoted 4 lines

Add

30))

I will let James add this tag.

Quoted 18 lines
Quoted 18 lines

---
v2: added link tag

? drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- ? 1 file changed, 2 insertions(+), 2 deletions(-)

drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index d60e2016d03c..e6c8e6d5234f 100644
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct 
 e1000_hw *hw, bool link)
 ? {

????? u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
????????? link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;

Quoted 8 lines
Quoted 6 lines

-??? u16 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ -??? u16 lat_enc_d = 0;??? /* latency decoded */
+??? u32 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ +??? u32 lat_enc_d = 0;??? /* latency decoded */
????? u16 lat_enc = 0;??? /* latency encoded */
????? if (link) {

The diff looks good.

Thanks

Quoted 5 lines

Kind regards,

Paul

Sasha

#4 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

Quoted 73 lines · Sasha,
Quoted 13 lines · Paul Menzel

Dear Sasha,

Thank you for your patch.

Am 05.04.22 um 17:56 schrieb Sasha Neftin:

Quoted 2 lines

When we decode the latency and the max_latency u16 value does not fill the required size

Do you mean ?fit into? or ?is too small for the required size??

Quoted 1 line

and could lead to the wrong LTR representation.

Quoted 7 lines

Maybe give an example of values leading to incorrect behavior?

Quoted 2 lines

Replace the u16 type with the u32 type and allow corrected LTR representation.

Maybe: Increase the variable size from u16 to u32, so the decoded latency can be represented. Why are 32 bit enough? Why not 64 bit?

Hello Paul,
Scaling represented as:

scale 0 - 1         (2^(5*0)) = 2^0
scale 1 - 32        (2^(5 *1))= 2^5
scale 2 - 1024      (2^(5 *2)) =2^10
scale 3 - 32768     (2^(5 *3)) =2^15
scale 4 ? 1048576   (2^(5 *4)) = 2^20
scale 5 ? 33554432  (2^(5 *4)) = 2^25

scale 4 and scale 5 required 20 and 25 bits respectively. scale 6 reserved.

Quoted 10 lines

Please use 75 characters per line.

Quoted 6 lines
Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for

10M")

Quoted 3 lines

Add

(rev

Quoted 1 line

30))

I will let James add this tag.

Quoted 18 lines
Quoted 18 lines

---
v2: added link tag

  drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index d60e2016d03c..e6c8e6d5234f 100644
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct
 e1000_hw *hw, bool link)
  {
      u32 reg = link << (E1000_LTRV_REQ_SHIFT +

E1000_LTRV_NOSNOOP_SHIFT) |

          link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
Quoted 8 lines

drivers/net/ethernet/intel/e1000e/ich8lan.c static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link) · line 1016

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/ich8lan.c +2 -2
-    u16 max_ltr_enc_d = 0;    /* maximum LTR decoded by platform */
-    u16 lat_enc_d = 0;    /* latency decoded */
+    u32 max_ltr_enc_d = 0;    /* maximum LTR decoded by platform */
+    u32 lat_enc_d = 0;    /* latency decoded */
      u16 lat_enc = 0;    /* latency encoded */
      if (link) {

The diff looks good.

Quoted 8 lines

Thanks

Quoted 5 lines

Kind regards,

Paul

Sasha

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20220406/0bda17e6/attachment-0001.html>

#5 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

In reply to Neftin

Dear Sasha, dear Tony,

Am 06.04.22 um 16:33 schrieb Neftin, Sasha:

Quoted 9 lines · Paul Menzel
Quoted 8 lines

Thank you for your patch.

Am 05.04.22 um 17:56 schrieb Sasha Neftin:

Quoted 2 lines

When we decode the latency and the max_latency u16 value does not fill the required size

Do you mean ?fit into? or ?is too small for the required size??

Tony, I saw you committed this patch [1]. Is it still possible to fix the wording?

Quoted 9 lines
Quoted 9 lines
Quoted 1 line

and could lead to the wrong LTR representation.

Maybe give an example of values leading to incorrect behavior?

Quoted 2 lines

Replace the u16 type with the u32 type and allow corrected LTR representation.

Maybe: Increase the variable size from u16 to u32, so the decoded latency can be represented. Why are 32 bit enough? Why not 64 bit?

Quoted 10 lines

Hello Paul,
Scaling represented as:
scale 0 - 1???????? (2^(5*0)) = 2^0
scale 1 - 32??????? (2^(5 *1))= 2^5
scale 2 - 1024????? (2^(5 *2)) =2^10
scale 3 - 32768???? (2^(5 *3)) =2^15
scale 4 ? 1048576?? (2^(5 *4)) = 2^20
scale 5 ? 33554432? (2^(5 *4)) = 2^25
scale 4 and scale 5 required 20 and 25 bits respectively. scale 6 reserved.

This would have been nice in the commit message.

Quoted 38 lines
Quoted 9 lines

Please use 75 characters per line.

Quoted 6 lines
Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency for

10M")

Quoted 3 lines

Add

I will let James add this tag.

Quoted 17 lines
Quoted 17 lines

---
v2: added link tag

? drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- ? 1 file changed, 2 insertions(+), 2 deletions(-)

drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index d60e2016d03c..e6c8e6d5234f 100644
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct 
 e1000_hw *hw, bool link)
 ? {

????? u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) | ????????? link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;

Quoted 8 lines
Quoted 6 lines

-??? u16 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ -??? u16 lat_enc_d = 0;??? /* latency decoded */
+??? u32 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ +??? u32 lat_enc_d = 0;??? /* latency decoded */
????? u16 lat_enc = 0;??? /* latency encoded */
????? if (link) {

The diff looks good.

Quoted 1 line

Thanks

Kind regards,

Paul

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git/commit/?h=dev-queue&id=7dd121b8d5735780b6a70db735d44b3e5b856130

maintainer
#6 lore raw

PATCH v2 1/1 e1000e: Fix possible overflow in LTR decoding

Quoted 8 lines · Paul Menzel

Dear Sasha, dear Tony,

Am 06.04.22 um 16:33 schrieb Neftin, Sasha:

Quoted 4 lines · Paul Menzel
Quoted 3 lines

Thank you for your patch.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

Am 05.04.22 um 17:56 schrieb Sasha Neftin:

Quoted 2 lines

When we decode the latency and the max_latency u16 value does not fill the required size

Do you mean ?fit into? or ?is too small for the required size??

Tony, I saw you committed this patch [1]. Is it still possible to fix the wording?

Yes, it can still be changed. I'll check with Sasha on any edits he wants to make before sending on to netdev.

Thanks,

Tony

Quoted 73 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

and could lead to the wrong LTR representation.

Maybe give an example of values leading to incorrect behavior?

Quoted 2 lines

Replace the u16 type with the u32 type and allow corrected LTR representation.

Maybe: Increase the variable size from u16 to u32, so the decoded latency can be represented. Why are 32 bit enough? Why not 64 bit?

Quoted 10 lines

Hello Paul,
Scaling represented as:
scale 0 - 1???????? (2^(5*0)) = 2^0
scale 1 - 32??????? (2^(5 *1))= 2^5
scale 2 - 1024????? (2^(5 *2)) =2^10
scale 3 - 32768???? (2^(5 *3)) =2^15
scale 4 ? 1048576?? (2^(5 *4)) = 2^20
scale 5 ? 33554432? (2^(5 *4)) = 2^25
scale 4 and scale 5 required 20 and 25 bits respectively. scale 6 reserved.

This would have been nice in the commit message.

Quoted 40 lines
Quoted 9 lines

Please use 75 characters per line.

Quoted 6 lines
Fixes 44a13a5d99c7 ("e1000e: Fix the max snoop/no-snoop latency

for 10M")

Quoted 4 lines

Add

(rev 30))

I will let James add this tag.

Quoted 18 lines
Quoted 18 lines

---
v2: added link tag

? drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- ? 1 file changed, 2 insertions(+), 2 deletions(-)

drivers/net/ethernet/intel/e1000e/ich8lan.c +0 -0
index d60e2016d03c..e6c8e6d5234f 100644
@@ -1009,8 +1009,8 @@ static s32 e1000_platform_pm_pch_lpt(struct 
 e1000_hw *hw, bool link)
 ? {

????? u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
????????? link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;

Quoted 8 lines
Quoted 6 lines

-??? u16 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ -??? u16 lat_enc_d = 0;??? /* latency decoded */
+??? u32 max_ltr_enc_d = 0;??? /* maximum LTR decoded by platform */ +??? u32 lat_enc_d = 0;??? /* latency decoded */
????? u16 lat_enc = 0;??? /* latency encoded */
????? if (link) {

The diff looks good.

Quoted 1 line

Thanks

Kind regards,

Paul

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git/commit/?h=dev-queue&id=7dd121b8d5735780b6a70db735d44b3e5b856130