diff mbox series

[v2] wifi: mac80211: check basic rates validity in sta_link_apply_parameters

Message ID 20250315130119.75937-1-m.lobanov@rosa.ru
State Superseded
Headers show
Series [v2] wifi: mac80211: check basic rates validity in sta_link_apply_parameters | expand

Commit Message

Mikhail Lobanov March 15, 2025, 1:01 p.m. UTC
When userspace sets supported rates for a new station via
NL80211_CMD_NEW_STATION, it might send a list that's empty
or contains only invalid values. Currently, we process these
values in sta_link_apply_parameters() without checking the result of
ieee80211_parse_bitrates(), which can lead to an empty rates bitmap.

A similar issue was addressed for NL80211_CMD_SET_BSS in commit
ce04abc3fcc6 ("wifi: mac80211: check basic rates validity").
This patch applies the same approach in sta_link_apply_parameters()
for NL80211_CMD_NEW_STATION, ensuring there is at least one valid
rate by inspecting the result of ieee80211_parse_bitrates().

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes: b95eb7f0eee4 ("wifi: cfg80211/mac80211: separate link params from station params")
Signed-off-by: Mikhail Lobanov <m.lobanov@rosa.ru>
---
v2: Fixed the patch subject to provide a complete description.

 net/mac80211/cfg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Christophe JAILLET March 15, 2025, 3:20 p.m. UTC | #1
Le 15/03/2025 à 14:01, Mikhail Lobanov a écrit :
> When userspace sets supported rates for a new station via
> NL80211_CMD_NEW_STATION, it might send a list that's empty
> or contains only invalid values. Currently, we process these
> values in sta_link_apply_parameters() without checking the result of
> ieee80211_parse_bitrates(), which can lead to an empty rates bitmap.
> 
> A similar issue was addressed for NL80211_CMD_SET_BSS in commit
> ce04abc3fcc6 ("wifi: mac80211: check basic rates validity").
> This patch applies the same approach in sta_link_apply_parameters()
> for NL80211_CMD_NEW_STATION, ensuring there is at least one valid
> rate by inspecting the result of ieee80211_parse_bitrates().
> 
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
> 
> Fixes: b95eb7f0eee4 ("wifi: cfg80211/mac80211: separate link params from station params")
> Signed-off-by: Mikhail Lobanov <m.lobanov-kcSV9N6+iMo@public.gmane.org>
> ---
> v2: Fixed the patch subject to provide a complete description.
> 
>   net/mac80211/cfg.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 9351c64608a9..e7c429aef980 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -1909,10 +1909,11 @@ static int sta_link_apply_parameters(struct ieee80211_local *local,
>   
>   	if (params->supported_rates &&
>   	    params->supported_rates_len) {
> -		ieee80211_parse_bitrates(link->conf->chanreq.oper.width,
> +		(!ieee80211_parse_bitrates(link->conf->chanreq.oper.width,

'if" missing?

>   					 sband, params->supported_rates,
>   					 params->supported_rates_len,
> -					 &link_sta->pub->supp_rates[sband->band]);
> +					 &link_sta->pub->supp_rates[sband->band]))
> +		return -EINVAL;
>   	}
>   
>   	if (params->ht_capa)
diff mbox series

Patch

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9351c64608a9..e7c429aef980 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1909,10 +1909,11 @@  static int sta_link_apply_parameters(struct ieee80211_local *local,
 
 	if (params->supported_rates &&
 	    params->supported_rates_len) {
-		ieee80211_parse_bitrates(link->conf->chanreq.oper.width,
+		(!ieee80211_parse_bitrates(link->conf->chanreq.oper.width,
 					 sband, params->supported_rates,
 					 params->supported_rates_len,
-					 &link_sta->pub->supp_rates[sband->band]);
+					 &link_sta->pub->supp_rates[sband->band]))
+		return -EINVAL;
 	}
 
 	if (params->ht_capa)