linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath10k: fix recent bandwidth conversion bug
@ 2017-11-01 20:01 Christian Lamparter
  2017-11-01 20:36 ` Sebastian Gottschall
  2017-11-01 20:37 ` Sebastian Gottschall
  0 siblings, 2 replies; 13+ messages in thread
From: Christian Lamparter @ 2017-11-01 20:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

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")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index a3f5dc78353f..26b0d201a698 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -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,
-- 
2.15.0

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-01 20:01 [PATCH] ath10k: fix recent bandwidth conversion bug Christian Lamparter
@ 2017-11-01 20:36 ` Sebastian Gottschall
  2017-11-01 20:37 ` Sebastian Gottschall
  1 sibling, 0 replies; 13+ messages in thread
From: Sebastian Gottschall @ 2017-11-01 20:36 UTC (permalink / raw)
  To: Christian Lamparter, linux-wireless; +Cc: Kalle Valo

true. good finding.

Am 01.11.2017 um 21:01 schrieb Christian Lamparter:
> 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")
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
> ---
>   drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
>   1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index a3f5dc78353f..26b0d201a698 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -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,


-- 
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: s.gottschall@dd-wrt.com
Tel.: +496251-582650 / Fax: +496251-5826565

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-01 20:01 [PATCH] ath10k: fix recent bandwidth conversion bug Christian Lamparter
  2017-11-01 20:36 ` Sebastian Gottschall
@ 2017-11-01 20:37 ` Sebastian Gottschall
  2017-11-02 19:34   ` Christian Lamparter
  1 sibling, 1 reply; 13+ messages in thread
From: Sebastian Gottschall @ 2017-11-01 20:37 UTC (permalink / raw)
  To: Christian Lamparter, linux-wireless; +Cc: Kalle Valo

a additional array bounds check would be good

Am 01.11.2017 um 21:01 schrieb Christian Lamparter:
> 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")
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
> ---
>   drivers/net/wireless/ath/ath10k/htt_rx.c | 23 +++++------------------
>   1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
> index a3f5dc78353f..26b0d201a698 100644
> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
> @@ -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,


-- 
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: s.gottschall@dd-wrt.com
Tel.: +496251-582650 / Fax: +496251-5826565

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-01 20:37 ` Sebastian Gottschall
@ 2017-11-02 19:34   ` Christian Lamparter
  2017-11-02 21:08     ` Sebastian Gottschall
  2017-11-20 11:57     ` Kalle Valo
  0 siblings, 2 replies; 13+ messages in thread
From: Christian Lamparter @ 2017-11-02 19:34 UTC (permalink / raw)
  To: Sebastian Gottschall; +Cc: linux-wireless, Kalle Valo

On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wrote:
> 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>


> > @@ -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,

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-02 19:34   ` Christian Lamparter
@ 2017-11-02 21:08     ` Sebastian Gottschall
  2017-11-13  8:53       ` Johannes Berg
  2017-11-20 11:57     ` Kalle Valo
  1 sibling, 1 reply; 13+ messages in thread
From: Sebastian Gottschall @ 2017-11-02 21:08 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: linux-wireless, Kalle Valo

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

Am 02.11.2017 um 20:34 schrieb Christian Lamparter:
> On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wrote:
>> 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>
>
>
>>> @@ -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,
>
>
>

-- 
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: s.gottschall@dd-wrt.com
Tel.: +496251-582650 / Fax: +496251-5826565

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-02 21:08     ` Sebastian Gottschall
@ 2017-11-13  8:53       ` Johannes Berg
  0 siblings, 0 replies; 13+ messages in thread
From: Johannes Berg @ 2017-11-13  8:53 UTC (permalink / raw)
  To: Sebastian Gottschall, Christian Lamparter; +Cc: linux-wireless, Kalle Valo

On Thu, 2017-11-02 at 22:08 +0100, Sebastian Gottschall wrote:
> 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

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-02 19:34   ` Christian Lamparter
  2017-11-02 21:08     ` Sebastian Gottschall
@ 2017-11-20 11:57     ` Kalle Valo
  2017-11-20 17:05       ` Christian Lamparter
  1 sibling, 1 reply; 13+ messages in thread
From: Kalle Valo @ 2017-11-20 11:57 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: Sebastian Gottschall, linux-wireless

Christian Lamparter <chunkeey@gmail.com> writes:

> On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wrote:
>> 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]=
:
> |	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=

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-20 11:57     ` Kalle Valo
@ 2017-11-20 17:05       ` Christian Lamparter
  2017-12-14 13:21         ` Kalle Valo
  0 siblings, 1 reply; 13+ messages in thread
From: Christian Lamparter @ 2017-11-20 17:05 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Sebastian Gottschall, linux-wireless

On Monday, November 20, 2017 11:57:21 AM CET Kalle Valo wrote:
> Christian Lamparter <chunkeey@gmail.com> writes:
> 
> > On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wrote:
> >> 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.
> 
> 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.

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-11-20 17:05       ` Christian Lamparter
@ 2017-12-14 13:21         ` Kalle Valo
  2018-03-01 11:52           ` Rafał Miłecki
  0 siblings, 1 reply; 13+ messages in thread
From: Kalle Valo @ 2017-12-14 13:21 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: Sebastian Gottschall, linux-wireless

Christian Lamparter <chunkeey@gmail.com> writes:

> On Monday, November 20, 2017 11:57:21 AM CET Kalle Valo wrote:
>> Christian Lamparter <chunkeey@gmail.com> writes:
>>=20
>> > On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wro=
te:
>> >> 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]:
>> > |	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.
>
> 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.

> 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>
>
> Is this really your signed-off-by or not?

I suspect that patch is taken from my pending branch.

> 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=

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2017-12-14 13:21         ` Kalle Valo
@ 2018-03-01 11:52           ` Rafał Miłecki
  2018-03-11  7:12             ` Kalle Valo
  0 siblings, 1 reply; 13+ messages in thread
From: Rafał Miłecki @ 2018-03-01 11:52 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Christian Lamparter, Sebastian Gottschall, linux-wireless

On 14 December 2017 at 14:21, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> Christian Lamparter <chunkeey@gmail.com> writes:
>
>> On Monday, November 20, 2017 11:57:21 AM CET Kalle Valo wrote:
>>> Christian Lamparter <chunkeey@gmail.com> writes:
>>>
>>> > On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall wr=
ote:
>>> >> 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]:
>>> > |  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)
>
> Sure, but after reading about all these security vulnerabilities I have
> become even more cautious and try to avoid all tricky stuff.
>
>> 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>
>>
>> Is this really your signed-off-by or not?
>
> I suspect that patch is taken from my pending branch.
>
>> 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

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2018-03-01 11:52           ` Rafał Miłecki
@ 2018-03-11  7:12             ` Kalle Valo
  2018-03-11 21:01               ` Rafał Miłecki
  0 siblings, 1 reply; 13+ messages in thread
From: Kalle Valo @ 2018-03-11  7:12 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Christian Lamparter, Sebastian Gottschall, linux-wireless

Rafa=C5=82 Mi=C5=82ecki <zajec5@gmail.com> writes:

> On 14 December 2017 at 14:21, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
>> Christian Lamparter <chunkeey@gmail.com> writes:
>>
>>> On Monday, November 20, 2017 11:57:21 AM CET Kalle Valo wrote:
>>>> Christian Lamparter <chunkeey@gmail.com> writes:
>>>>
>>>> > On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall w=
rote:
>>>> >> 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]:
>>>> > |  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)
>>
>> Sure, but after reading about all these security vulnerabilities I have
>> become even more cautious and try to avoid all tricky stuff.
>>
>>> 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>
>>>
>>> Is this really your signed-off-by or not?
>>
>> I suspect that patch is taken from my pending branch.
>>
>>> 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?

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

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

* Re: [PATCH] ath10k: fix recent bandwidth conversion bug
  2018-03-11  7:12             ` Kalle Valo
@ 2018-03-11 21:01               ` Rafał Miłecki
  0 siblings, 0 replies; 13+ messages in thread
From: Rafał Miłecki @ 2018-03-11 21:01 UTC (permalink / raw)
  To: Kalle Valo; +Cc: Christian Lamparter, Sebastian Gottschall, linux-wireless

On 11 March 2018 at 08:12, Kalle Valo <kvalo@codeaurora.org> wrote:
> Rafa=C5=82 Mi=C5=82ecki <zajec5@gmail.com> writes:
>
>> On 14 December 2017 at 14:21, Kalle Valo <kvalo@qca.qualcomm.com> wrote:
>>> Christian Lamparter <chunkeey@gmail.com> writes:
>>>
>>>> On Monday, November 20, 2017 11:57:21 AM CET Kalle Valo wrote:
>>>>> Christian Lamparter <chunkeey@gmail.com> writes:
>>>>>
>>>>> > On Wednesday, November 1, 2017 9:37:53 PM CET Sebastian Gottschall =
wrote:
>>>>> >> 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]:
>>>>> > |  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)
>>>
>>> Sure, but after reading about all these security vulnerabilities I have
>>> become even more cautious and try to avoid all tricky stuff.
>>>
>>>> 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>
>>>>
>>>> Is this really your signed-off-by or not?
>>>
>>> I suspect that patch is taken from my pending branch.
>>>
>>>> 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?
>
> 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

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

* [PATCH] ath10k: fix recent bandwidth conversion bug
@ 2018-03-10 12:20 Anilkumar Kolli
  0 siblings, 0 replies; 13+ messages in thread
From: Anilkumar Kolli @ 2018-03-10 12:20 UTC (permalink / raw)
  To: ath10k; +Cc: linux-wireless

From: Christian Lamparter <chunkeey@gmail.com>

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().

This will fix below warning,

 WARNING: CPU: 0 PID: 609 at net/wireless/util.c:1254
 cfg80211_calculate_bitrate+0x174/0x220
 invalid rate bw=1, mcs=9, nss=2

 (unwind_backtrace) from
 (cfg80211_calculate_bitrate+0x174/0x220)
 (cfg80211_calculate_bitrate) from
 (nl80211_put_sta_rate+0x44/0x1dc)from
 (nl80211_put_sta_rate) from
 (nl80211_send_station+0x388/0xaf0)
 (nl80211_get_station+0xa8/0xec)
 [ end trace da8257d6a850e91a ]

Fixes: 842be75c77cb ("cfg80211: make RATE_INFO_BW_20 the default")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/htt_rx.c |   43 +++++++++++++++++-------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index 6d96f9560950..47d1f2f6c6bb 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005-2011 Atheros Communications Inc.
  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -723,6 +724,28 @@ struct amsdu_subframe_hdr {
 
 #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
 
+static inline u8 ath10k_bw_to_mac80211_bw(u8 bw)
+{
+	u8 ret = 0;
+
+	switch (bw) {
+	case 0:
+		ret = RATE_INFO_BW_20;
+		break;
+	case 1:
+		ret = RATE_INFO_BW_40;
+		break;
+	case 2:
+		ret = RATE_INFO_BW_80;
+		break;
+	case 3:
+		ret = RATE_INFO_BW_160;
+		break;
+	}
+
+	return ret;
+}
+
 static void ath10k_htt_rx_h_rates(struct ath10k *ar,
 				  struct ieee80211_rx_status *status,
 				  struct htt_rx_desc *rxd)
@@ -825,23 +848,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(bw);
 		status->encoding = RX_ENC_VHT;
 		break;
 	default:
@@ -2499,7 +2506,7 @@ static inline bool is_valid_legacy_rate(u8 rate)
 		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_bw(txrate.bw);
 }
 
 static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
-- 
1.7.9.5

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

end of thread, other threads:[~2018-03-11 21:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 20:01 [PATCH] ath10k: fix recent bandwidth conversion bug Christian Lamparter
2017-11-01 20:36 ` Sebastian Gottschall
2017-11-01 20:37 ` Sebastian Gottschall
2017-11-02 19:34   ` Christian Lamparter
2017-11-02 21:08     ` Sebastian Gottschall
2017-11-13  8:53       ` Johannes Berg
2017-11-20 11:57     ` Kalle Valo
2017-11-20 17:05       ` Christian Lamparter
2017-12-14 13:21         ` Kalle Valo
2018-03-01 11:52           ` Rafał Miłecki
2018-03-11  7:12             ` Kalle Valo
2018-03-11 21:01               ` Rafał Miłecki
2018-03-10 12:20 Anilkumar Kolli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).