Skip to contentSkip to conversation

ath10k: fix recent bandwidth conversion bug

PATCH In review Christian Lamparter 6 participants 12 messages Nov 1, 2017 – Mar 11, 2018 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: fix recent bandwidth conversion bug

The commit "cfg80211: make RATE_INFO_BW_20 the default" changed the index of RATE_INFO_BW_20, but the updates to ath10k missed the special bandwidth calculation case in ath10k_update_per_peer_tx_stats().

Fixes 842be75c77cb ("cfg80211: make RATE_INFO_BW_20 the default")
---
 drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +5 -18
index a3f5dc78353f..26b0d201a698 100644
@@ -592,6 +592,9 @@ struct amsdu_subframe_hdr {
 
 #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static const u8 ath10k_bw_to_mac80211[] = { RATE_INFO_BW_20, RATE_INFO_BW_40,
+	RATE_INFO_BW_80, RATE_INFO_BW_160 };
+
 static void ath10k_htt_rx_h_rates(struct ath10k *ar,
 				  struct ieee80211_rx_status *status,
 				  struct htt_rx_desc *rxd)
@@ -694,23 +697,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
 		if (sgi)
 			status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
-		switch (bw) {
-		/* 20MHZ */
-		case 0:
-			break;
-		/* 40MHZ */
-		case 1:
-			status->bw = RATE_INFO_BW_40;
-			break;
-		/* 80MHZ */
-		case 2:
-			status->bw = RATE_INFO_BW_80;
-			break;
-		case 3:
-			status->bw = RATE_INFO_BW_160;
-			break;
-		}
-
+		status->bw = ath10k_bw_to_mac80211[bw];
 		status->encoding = RX_ENC_VHT;
 		break;
 	default:
@@ -2297,7 +2284,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
 		arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
 	arsta->txrate.nss = txrate.nss;
-	arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
+	arsta->txrate.bw = ath10k_bw_to_mac80211[txrate.bw];
 }
 
 static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
Signature · 1 line
2.15.0
#1 lore raw

true. good finding.

Am 01.11.2017 um 21:01 schrieb Christian Lamparter:

Quoted 59 lines

The commit "cfg80211: make RATE_INFO_BW_20 the default" changed the index of RATE_INFO_BW_20, but the updates to ath10k missed the special bandwidth calculation case in ath10k_update_per_peer_tx_stats().

Fixes 842be75c77cb ("cfg80211: make RATE_INFO_BW_20 the default")
---
  drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
  1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +5 -18
index a3f5dc78353f..26b0d201a698 100644
@@ -592,6 +592,9 @@ struct amsdu_subframe_hdr {
 
  #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static const u8 ath10k_bw_to_mac80211[] = { RATE_INFO_BW_20, RATE_INFO_BW_40,
+	RATE_INFO_BW_80, RATE_INFO_BW_160 };
+
  static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  				  struct ieee80211_rx_status *status,
  				  struct htt_rx_desc *rxd)
@@ -694,23 +697,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  		if (sgi)
  			status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
-		switch (bw) {
-		/* 20MHZ */
-		case 0:
-			break;
-		/* 40MHZ */
-		case 1:
-			status->bw = RATE_INFO_BW_40;
-			break;
-		/* 80MHZ */
-		case 2:
-			status->bw = RATE_INFO_BW_80;
-			break;
-		case 3:
-			status->bw = RATE_INFO_BW_160;
-			break;
-		}
-
+		status->bw = ath10k_bw_to_mac80211[bw];
  		status->encoding = RX_ENC_VHT;
  		break;
  	default:
@@ -2297,7 +2284,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
  		arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
  	arsta->txrate.nss = txrate.nss;
-	arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
+	arsta->txrate.bw = ath10k_bw_to_mac80211[txrate.bw];
  }
 
  static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
Signature · 11 lines
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

NewMedia-NET GmbH - DD-WRT
Firmensitz:  Stubenwaldallee 21a, 64625 Bensheim
Registergericht: Amtsgericht Darmstadt, HRB 25473
Geschäftsführer: Peter Steinhäuser, Christian Scheele
http://www.dd-wrt.com
email: [email protected]
Tel.: +496251-582650 / Fax: +496251-5826565
#2 lore raw
In reply to Christian Lamparter

a additional array bounds check would be good

Am 01.11.2017 um 21:01 schrieb Christian Lamparter:

Quoted 59 lines

The commit "cfg80211: make RATE_INFO_BW_20 the default" changed the index of RATE_INFO_BW_20, but the updates to ath10k missed the special bandwidth calculation case in ath10k_update_per_peer_tx_stats().

Fixes 842be75c77cb ("cfg80211: make RATE_INFO_BW_20 the default")
---
  drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
  1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +5 -18
index a3f5dc78353f..26b0d201a698 100644
@@ -592,6 +592,9 @@ struct amsdu_subframe_hdr {
 
  #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static const u8 ath10k_bw_to_mac80211[] = { RATE_INFO_BW_20, RATE_INFO_BW_40,
+	RATE_INFO_BW_80, RATE_INFO_BW_160 };
+
  static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  				  struct ieee80211_rx_status *status,
  				  struct htt_rx_desc *rxd)
@@ -694,23 +697,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  		if (sgi)
  			status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
-		switch (bw) {
-		/* 20MHZ */
-		case 0:
-			break;
-		/* 40MHZ */
-		case 1:
-			status->bw = RATE_INFO_BW_40;
-			break;
-		/* 80MHZ */
-		case 2:
-			status->bw = RATE_INFO_BW_80;
-			break;
-		case 3:
-			status->bw = RATE_INFO_BW_160;
-			break;
-		}
-
+		status->bw = ath10k_bw_to_mac80211[bw];
  		status->encoding = RX_ENC_VHT;
  		break;
  	default:
@@ -2297,7 +2284,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
  		arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
  	arsta->txrate.nss = txrate.nss;
-	arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
+	arsta->txrate.bw = ath10k_bw_to_mac80211[txrate.bw];
  }
 
  static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
Signature · 11 lines
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

NewMedia-NET GmbH - DD-WRT
Firmensitz:  Stubenwaldallee 21a, 64625 Bensheim
Registergericht: Amtsgericht Darmstadt, HRB 25473
Geschäftsführer: Peter Steinhäuser, Christian Scheele
http://www.dd-wrt.com
email: [email protected]
Tel.: +496251-582650 / Fax: +496251-5826565
#3 lore raw
Quoted 1 line · CET Sebastian Gottschall

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw = info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by [1]:
| txrate.bw = ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

[0] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/htt_rx.c#L646>

[1] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/htt_rx.c#L2254>
[2] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/wmi.h#L4810>

Quoted 28 lines
Quoted 28 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +5 -1
@@ -592,6 +592,9 @@ struct amsdu_subframe_hdr {
 
  #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static const u8 ath10k_bw_to_mac80211[] = { RATE_INFO_BW_20, RATE_INFO_BW_40,
+	RATE_INFO_BW_80, RATE_INFO_BW_160 };
+
  static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  				  struct ieee80211_rx_status *status,
  				  struct htt_rx_desc *rxd)
@@ -694,23 +697,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
  		if (sgi)
  			status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
[...]
+		status->bw = ath10k_bw_to_mac80211[bw];
  		status->encoding = RX_ENC_VHT;
  		break;
  	default:
@@ -2297,7 +2284,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
  		arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
  	arsta->txrate.nss = txrate.nss;
-	arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
+	arsta->txrate.bw = ath10k_bw_to_mac80211[txrate.bw];
  }
 
  static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
#4 lore raw

i know. saw that later too. code should be safe

Am 02.11.2017 um 20:34 schrieb Christian Lamparter:

Quoted 54 lines · CET Sebastian Gottschall
Quoted 1 line

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw = info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by [1]:
| txrate.bw = ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

[0] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/htt_rx.c#L646>

[1] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/htt_rx.c#L2254>
[2] <https://elixir.free-electrons.com/linux/v4.14-rc7/source/drivers/net/wireless/ath/ath10k/wmi.h#L4810>

Quoted 28 lines
Quoted 28 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +5 -1
@@ -592,6 +592,9 @@ struct amsdu_subframe_hdr {
 
   #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static const u8 ath10k_bw_to_mac80211[] = { RATE_INFO_BW_20, RATE_INFO_BW_40,
+	RATE_INFO_BW_80, RATE_INFO_BW_160 };
+
   static void ath10k_htt_rx_h_rates(struct ath10k *ar,
   				  struct ieee80211_rx_status *status,
   				  struct htt_rx_desc *rxd)
@@ -694,23 +697,7 @@ static void ath10k_htt_rx_h_rates(struct ath10k *ar,
   		if (sgi)
   			status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
[...]
+		status->bw = ath10k_bw_to_mac80211[bw];
   		status->encoding = RX_ENC_VHT;
   		break;
   	default:
@@ -2297,7 +2284,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
   		arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 
   	arsta->txrate.nss = txrate.nss;
-	arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
+	arsta->txrate.bw = ath10k_bw_to_mac80211[txrate.bw];
   }
 
   static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
Signature · 11 lines
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

NewMedia-NET GmbH - DD-WRT
Firmensitz:  Stubenwaldallee 21a, 64625 Bensheim
Registergericht: Amtsgericht Darmstadt, HRB 25473
Geschäftsführer: Peter Steinhäuser, Christian Scheele
http://www.dd-wrt.com
email: [email protected]
Tel.: +496251-582650 / Fax: +496251-5826565
#5 lore raw
Quoted 1 line · Sebastian Gottschall

i know. saw that later too. code should be safe

It would be good if you could adhere to our mailing list customs and start quoting properly, instead of just top-posting.

Thanks,
johannes

#6 lore raw
In reply to Christian Lamparter
Quoted 10 lines · Christian Lamparter
Quoted 1 line · CET Sebastian Gottschall

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw =3D info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by [1]=

:

Quoted 7 lines

| txrate.bw =3D ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

--=20
Kalle Valo=

#7 lore raw
Quoted 17 lines · CET Kalle Valo
Quoted 15 lines · Christian Lamparter
Quoted 1 line · CET Sebastian Gottschall

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw = info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by [1]:
| txrate.bw = ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

Quoted 6 lines
Quoted 2 lines

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

The kbuild-bot/CI can catch this too.

For example, it will look like this:
drivers/net/wireless/ath/ath10k//htt_rx.c:710:52: warning: invalid access past the end of 'ath10k_bw_to_mac80211' (4 4)

BTW:
Have you noticed:

<https://github.com/lede-project/source/blob/master/package/kernel/mac80211/patches/319-ath10k-fix-recent-bandwidth-conversion-bug.patch>

Is this really your signed-off-by or not?

In any case, you - as the maintainer - can modify the patch as you see fit. So, please do so.

#8 lore raw
Quoted 4 lines · Christian Lamparter
Quoted 3 lines · CET Kalle Valo

Christian Lamparter <[email protected]> writes:
=20

Quoted 1 line

On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wro=

te:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw =3D info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by =

[1]:

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

| txrate.bw =3D ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

=20
Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

Quoted 5 lines

The kbuild-bot/CI can catch this too.=20

For example, it will look like this:
drivers/net/wireless/ath/ath10k//htt_rx.c:710:52: warning: invalid access past the end of 'ath10k_bw_to_mac80211' (4 4)

Sure, but after reading about all these security vulnerabilities I have become even more cautious and try to avoid all tricky stuff.

Quoted 4 lines

BTW:
Have you noticed:

<https://github.com/lede-project/source/blob/master/package/kernel/mac802=

11/patches/319-ath10k-fix-recent-bandwidth-conversion-bug.patch>

Quoted 2 lines

Is this really your signed-off-by or not?

I suspect that patch is taken from my pending branch.

Quoted 2 lines

In any case, you - as the maintainer - can modify the patch as you see fit. So, please do so.

Ok, we'll send v2.

--=20
Kalle Valo=

#9 lore raw
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Christian Lamparter
Quoted 3 lines · CET Kalle Valo
Quoted 1 line · Christian Lamparter

On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wr=

ote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw =3D info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set by=

[1]:

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

| txrate.bw =3D ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

Quoted 13 lines
Quoted 5 lines

The kbuild-bot/CI can catch this too.

For example, it will look like this:
drivers/net/wireless/ath/ath10k//htt_rx.c:710:52: warning: invalid access past the end of 'ath10k_bw_to_mac80211' (4 4)

Sure, but after reading about all these security vulnerabilities I have become even more cautious and try to avoid all tricky stuff.

Quoted 4 lines

BTW:
Have you noticed:

<https://github.com/lede-project/source/blob/master/package/kernel/mac80=

211/patches/319-ath10k-fix-recent-bandwidth-conversion-bug.patch>

Quoted 9 lines
Quoted 2 lines

Is this really your signed-off-by or not?

I suspect that patch is taken from my pending branch.

Quoted 2 lines

In any case, you - as the maintainer - can modify the patch as you see fit. So, please do so.

Ok, we'll send v2.

Hi Kalle,

I'm trying to figure out the fate of that LEDE's patch. I don't think you ever sent V2.

Is that fix still needed? Are you planning to send V2?

--=20
Rafa=C5=82

#10 lore raw
Quoted 7 lines · Rafa=C5=82 Mi=C5=82ecki <[email protected]> writes:
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Christian Lamparter
Quoted 3 lines · CET Kalle Valo
Quoted 1 line · Christian Lamparter

On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall w=

rote:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw =3D info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set b=

y [1]:

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 11 lines
Quoted 7 lines

| txrate.bw =3D ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

The kbuild-bot/CI can catch this too.

For example, it will look like this:
drivers/net/wireless/ath/ath10k//htt_rx.c:710:52: warning: invalid access past the end of 'ath10k_bw_to_mac80211' (4 4)

Quoted 7 lines
Quoted 7 lines

Sure, but after reading about all these security vulnerabilities I have become even more cautious and try to avoid all tricky stuff.

Quoted 4 lines

BTW:
Have you noticed:

<https://github.com/lede-project/source/blob/master/package/kernel/mac8=

0211/patches/319-ath10k-fix-recent-bandwidth-conversion-bug.patch>

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Is this really your signed-off-by or not?

I suspect that patch is taken from my pending branch.

Quoted 2 lines

In any case, you - as the maintainer - can modify the patch as you see fit. So, please do so.

Quoted 8 lines
Quoted 1 line

Ok, we'll send v2.

Hi Kalle,

I'm trying to figure out the fate of that LEDE's patch. I don't think you ever sent V2.

Is that fix still needed? Are you planning to send V2?

Anil now sent v2 (he just forgot to mark it as such):

https://patchwork.kernel.org/patch/10273445/

Thanks for the reminder.

--=20
Kalle Valo

#11 lore raw
Quoted 9 lines · Kalle Valo
Quoted 7 lines · Rafa=C5=82 Mi=C5=82ecki <[email protected]> writes:
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Christian Lamparter
Quoted 3 lines · CET Kalle Valo
Quoted 1 line · Christian Lamparter

On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall =

Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

a additional array bounds check would be good

Ah, about that:

the bw variable in ath10k_htt_rx_h_rates() is extracted from info2 in the following way [0]:
| bw =3D info2 & 3;

the txrate.bw variable in ath10k_update_per_peer_tx_stats() is set =

by [1]:

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 11 lines
Quoted 7 lines

| txrate.bw =3D ATH10K_HW_BW(peer_stats->flags);

ATH10K_HW_BW is a macro defined as [2]:
| #define ATH10K_HW_BW(flags) (((flags) >> 3) & 0x3)

In both cases the bandwidth values already are limited to 0-3 by the "and 3" operation.

Until someone changes that part of the code (and the firmware interface). IMHO a switch is safer as there we don't have any risk of out of bands access.

The kbuild-bot/CI can catch this too.

For example, it will look like this:
drivers/net/wireless/ath/ath10k//htt_rx.c:710:52: warning: invalid access past the end of 'ath10k_bw_to_mac80211' (4 4)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Sure, but after reading about all these security vulnerabilities I have become even more cautious and try to avoid all tricky stuff.

Quoted 4 lines

BTW:
Have you noticed:

<https://github.com/lede-project/source/blob/master/package/kernel/mac=

80211/patches/319-ath10k-fix-recent-bandwidth-conversion-bug.patch>

Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 2 lines

Is this really your signed-off-by or not?

I suspect that patch is taken from my pending branch.

Quoted 2 lines

In any case, you - as the maintainer - can modify the patch as you see fit. So, please do so.

Ok, we'll send v2.

Hi Kalle,

I'm trying to figure out the fate of that LEDE's patch. I don't think you ever sent V2.

Quoted 7 lines
Quoted 1 line

Is that fix still needed? Are you planning to send V2?

Anil now sent v2 (he just forgot to mark it as such):

https://patchwork.kernel.org/patch/10273445/

Thanks for the reminder.

Thanks!

--=20
Rafa=C5=82