linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: mac80211: avoid warning of no supported legacy rate if empty rate mask for rate control
@ 2024-07-26  3:15 Ping-Ke Shih
  2024-07-26 10:30 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Ping-Ke Shih @ 2024-07-26  3:15 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless

The commit 9df66d5b9f45 ("cfg80211: fix default HE tx bitrate mask in 2G
band") correct bitmask of HE MCS, and settings of empty legacy rate plus
HE MCS rate are correctly recognized instead of returning -EINVAL,
so empty legacy rate propagates to __rate_control_send_low() and warn
no supported rate.

Since the rate_mask is intentionally set to empty via nl80211, change logic
to avoid warning no supported rate if rate_mask is empty.

Reported-by: syzbot+8dd98a9e98ee28dc484a@syzkaller.appspotmail.com
Fixes: 9df66d5b9f45 ("cfg80211: fix default HE tx bitrate mask in 2G band")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 net/mac80211/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 4dc1def69548..5787cb20de42 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -377,7 +377,7 @@ static void __rate_control_send_low(struct ieee80211_hw *hw,
 		info->control.rates[0].idx = i;
 		break;
 	}
-	WARN_ONCE(i == sband->n_bitrates,
+	WARN_ONCE(i == sband->n_bitrates && rate_mask,
 		  "no supported rates for sta %pM (0x%x, band %d) in rate_mask 0x%x with flags 0x%x\n",
 		  sta ? sta->addr : NULL,
 		  sta ? sta->deflink.supp_rates[sband->band] : -1,
-- 
2.25.1


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

* Re: [PATCH] wifi: mac80211: avoid warning of no supported legacy rate if empty rate mask for rate control
  2024-07-26  3:15 [PATCH] wifi: mac80211: avoid warning of no supported legacy rate if empty rate mask for rate control Ping-Ke Shih
@ 2024-07-26 10:30 ` Johannes Berg
  2024-07-29  7:51   ` Ping-Ke Shih
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2024-07-26 10:30 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: linux-wireless

Hi PK,

Thanks for taking a lot at the syzbot report! It's been on my list for a
while, but didn't get to it.

> The commit 9df66d5b9f45 ("cfg80211: fix default HE tx bitrate mask in 2G
> band") correct bitmask of HE MCS, and settings of empty legacy rate plus
> HE MCS rate are correctly recognized instead of returning -EINVAL,
> so empty legacy rate propagates to __rate_control_send_low() and warn
> no supported rate.
> 
> Since the rate_mask is intentionally set to empty via nl80211, 

That's all true, however,

> change logic
> to avoid warning no supported rate if rate_mask is empty.

I don't necessarily think this follows.

> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index 4dc1def69548..5787cb20de42 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -377,7 +377,7 @@ static void __rate_control_send_low(struct ieee80211_hw *hw,
>  		info->control.rates[0].idx = i;
>  		break;
>  	}
> -	WARN_ONCE(i == sband->n_bitrates,
> +	WARN_ONCE(i == sband->n_bitrates && rate_mask,
>  		  "no supported rates for sta %pM (0x%x, band %d) in rate_mask 0x%x with flags 0x%x\n",
>  		  sta ? sta->addr : NULL,
>  		  sta ? sta->deflink.supp_rates[sband->band] : -1,

The warning is still valid - we're trying to pick a low rate with a NULL
station (i.e. we don't even really know where to send the frame), but we
don't have any rates to do so with.

Obviously this will remove the warning in this case, but I think the
underlying issue is that we're actually using the rate mask, intended
for the connection on the interface, for offchannel TX (looking at the
stack dump).

We had this precise discussion previously for scanning, and just like
there, fixed in ab9177d83c04 ("wifi: mac80211: don't use rate mask for
scanning"), I feel the right way to approach this issue here would be to
similarly not use the rate mask for offchannel TX, which is I think
pretty much the same situation, you could have a rate mask set for only
2.4 GHz where the connection is (and empty for other bands), which is
accepted by cfg80211 and mac80211, but then do offchannel TX on 5 GHz
anyway.

So I think the right way to approach this would be to do something like 

diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 28d03196ef75..33361b4d9acf 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -830,6 +830,8 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 		flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
 			IEEE80211_TX_CTL_REQ_TX_STATUS;
 
+	flags |= IEEE80211_TX_CTRL_SCAN_TX;
+
 	if (params->no_cck)
 		flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
 

though at that point we need to rename that flag too, I guess.


johannes

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

* RE: [PATCH] wifi: mac80211: avoid warning of no supported legacy rate if empty rate mask for rate control
  2024-07-26 10:30 ` Johannes Berg
@ 2024-07-29  7:51   ` Ping-Ke Shih
  0 siblings, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2024-07-29  7:51 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org

Johannes Berg <johannes@sipsolutions.net> wrote:
> 
> We had this precise discussion previously for scanning, and just like
> there, fixed in ab9177d83c04 ("wifi: mac80211: don't use rate mask for
> scanning"), I feel the right way to approach this issue here would be to
> similarly not use the rate mask for offchannel TX, which is I think
> pretty much the same situation, you could have a rate mask set for only
> 2.4 GHz where the connection is (and empty for other bands), which is
> accepted by cfg80211 and mac80211, but then do offchannel TX on 5 GHz
> anyway.
> 
> So I think the right way to approach this would be to do something like
> 
> diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
> index 28d03196ef75..33361b4d9acf 100644
> --- a/net/mac80211/offchannel.c
> +++ b/net/mac80211/offchannel.c
> @@ -830,6 +830,8 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
>                 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
>                         IEEE80211_TX_CTL_REQ_TX_STATUS;
> 
> +       flags |= IEEE80211_TX_CTRL_SCAN_TX;
> +
>         if (params->no_cck)
>                 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
> 
> 
> though at that point we need to rename that flag too, I guess.

Thanks for the suggestions. I made and sent a patch [1] that works well in
my side using syzbot's reproducer code. 

[1] https://lore.kernel.org/linux-wireless/20240729074816.20323-1-pkshih@realtek.com/T/#u



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

end of thread, other threads:[~2024-07-29  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26  3:15 [PATCH] wifi: mac80211: avoid warning of no supported legacy rate if empty rate mask for rate control Ping-Ke Shih
2024-07-26 10:30 ` Johannes Berg
2024-07-29  7:51   ` Ping-Ke Shih

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