Skip to contentSkip to conversation

nl80211/cfg80211: add nla_policy for S1G band

PATCH In review Lin Ma 3 participants 7 messages Jan 19, 2024 – Jan 25, 2024

Subsystems (3)
lore
Share & tools
lore

Lin Ma

author
#0 lore raw

PATCH v2 1/1 nl80211/cfg80211: add nla_policy for S1G band

Our detector has identified another case of an incomplete policy. Specifically, the commit df78a0c0b67d ("nl80211: S1G band and channel definitions") introduced the NL80211_BAND_S1GHZ attribute to nl80211_band, but it neglected to update the nl80211_match_band_rssi_policy accordingly.

Similar commits that add new band types, such as the initial commit 1e1b11b6a111 ("nl80211/cfg80211: Specify band specific min RSSI thresholds with sched scan"), the commit e548a1c36b11 ("cfg80211: add 6GHz in code handling array with NUM_NL80211_BANDS entries"), and the commit 63fa04266629 ("nl80211: Add LC placeholder band definition to nl80211_band"), all require updates to the policy.
Failure to do so could result in accessing an attribute of unexpected length in the function nl80211_parse_sched_scan_per_band_rssi.

To resolve this issue, this commit adds the policy for the NL80211_BAND_S1GHZ attribute.

Fixes df78a0c0b67d ("nl80211: S1G band and channel definitions")

---
V1 -> V2: change net-next to wireless as suggested

 net/wireless/nl80211.c | 1 +
 1 file changed, 1 insertion(+)
net/wireless/nl80211.c +1 -0
index 60877b532993..980300621a60 100644
@@ -911,6 +911,7 @@ nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = {
 	[NL80211_BAND_5GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_6GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_60GHZ] = { .type = NLA_S32 },
+	[NL80211_BAND_S1GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_LC]    = { .type = NLA_S32 },
 };
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 2 lines · Lin Ma

V1 -> V2: change net-next to wireless as suggested

For the record, I don't think anyone is using scheduled scan with S1G or even _could_ be doing that (is there even a driver other than hwsim?), so I don't think I'll apply this for wireless. No need to resend (again) though :)

johannes

#2 lore raw
In reply to Lin Ma
Quoted 31 lines · Lin Ma

Our detector has identified another case of an incomplete policy. Specifically, the commit df78a0c0b67d ("nl80211: S1G band and channel definitions") introduced the NL80211_BAND_S1GHZ attribute to nl80211_band, but it neglected to update the nl80211_match_band_rssi_policy accordingly.

Similar commits that add new band types, such as the initial commit 1e1b11b6a111 ("nl80211/cfg80211: Specify band specific min RSSI thresholds with sched scan"), the commit e548a1c36b11 ("cfg80211: add 6GHz in code handling array with NUM_NL80211_BANDS entries"), and the commit 63fa04266629 ("nl80211: Add LC placeholder band definition to nl80211_band"), all require updates to the policy.
Failure to do so could result in accessing an attribute of unexpected length in the function nl80211_parse_sched_scan_per_band_rssi.

To resolve this issue, this commit adds the policy for the NL80211_BAND_S1GHZ attribute.

Fixes df78a0c0b67d ("nl80211: S1G band and channel definitions")

---
V1 -> V2: change net-next to wireless as suggested

 net/wireless/nl80211.c | 1 +
 1 file changed, 1 insertion(+)
net/wireless/nl80211.c +0 -0
index 60877b532993..980300621a60 100644

net/wireless/nl80211.c nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = { · line 917

Quoted 7 lines
net/wireless/nl80211.c +1 -0
@@ -911,6 +911,7 @@ nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = {
 	[NL80211_BAND_5GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_6GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_60GHZ] = { .type = NLA_S32 },
+	[NL80211_BAND_S1GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_LC]    = { .type = NLA_S32 },
 };
 

something is really suspicious since the NL80211_BAND_* enums are *value* enums, not attribute ID enums, and hence they should never be used in an nla_policy.

what is actually using these as attribute IDs, noting that NL80211_BAND_2GHZ == 0 and hence cannot be used as an attribute ID

seems the logic that introduced this policy needs to be revisited.

maintainer
#3 lore raw
Quoted 5 lines · Jeff Johnson
Quoted 5 lines
net/wireless/nl80211.c +0 -0
@@ -911,6 +911,7 @@ nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = {
 	[NL80211_BAND_5GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_6GHZ] = { .type = NLA_S32 },
Quoted 8 lines

net/wireless/nl80211.c nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = { · line 917

Quoted 5 lines
net/wireless/nl80211.c +1 -0
 	[NL80211_BAND_60GHZ] = { .type = NLA_S32 },
+	[NL80211_BAND_S1GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_LC]    = { .type = NLA_S32 },
 };
 

something is really suspicious since the NL80211_BAND_* enums are *value* enums, not attribute ID enums, and hence they should never be used in an nla_policy.

Yeah, that's what it looks like first, but then they do get used anyway...

Quoted 2 lines

what is actually using these as attribute IDs, noting that NL80211_BAND_2GHZ == 0 and hence cannot be used as an attribute ID

Ohh. Good catch!

Quoted 2 lines

seems the logic that introduced this policy needs to be revisited.

Let's just remove it?

commit 1e1b11b6a1111cd9e8af1fd6ccda270a9fa3eacf

Author: vamsi krishna <[email protected]>
Date:   Fri Feb 1 18:34:51 2019 +0530

nl80211/cfg80211: Specify band specific min RSSI thresholds with sched scan

As far as I can tell nothing is using that in the first place ... Certainly not in the kernel, nor wpa_s, nor anything else I could find really ...

We can't completely revert it since we need the attribute number to stay allocated, but that's all we cannot remove.

johannes

#4 lore raw
Quoted 35 lines · Johannes Berg
Quoted 5 lines · Jeff Johnson
Quoted 5 lines
net/wireless/nl80211.c +0 -0
@@ -911,6 +911,7 @@ nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = {
 	[NL80211_BAND_5GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_6GHZ] = { .type = NLA_S32 },
Quoted 8 lines

net/wireless/nl80211.c nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = { · line 917

Quoted 5 lines
net/wireless/nl80211.c +1 -0
 	[NL80211_BAND_60GHZ] = { .type = NLA_S32 },
+	[NL80211_BAND_S1GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_LC]    = { .type = NLA_S32 },
 };
 

something is really suspicious since the NL80211_BAND_* enums are *value* enums, not attribute ID enums, and hence they should never be used in an nla_policy.

Yeah, that's what it looks like first, but then they do get used anyway...

Quoted 2 lines

what is actually using these as attribute IDs, noting that NL80211_BAND_2GHZ == 0 and hence cannot be used as an attribute ID

Ohh. Good catch!

Quoted 2 lines

seems the logic that introduced this policy needs to be revisited.

Let's just remove it?

commit 1e1b11b6a1111cd9e8af1fd6ccda270a9fa3eacf

Author: vamsi krishna <[email protected]>
Date:   Fri Feb 1 18:34:51 2019 +0530

nl80211/cfg80211: Specify band specific min RSSI thresholds with sched scan

Quoted 6 lines

As far as I can tell nothing is using that in the first place ... Certainly not in the kernel, nor wpa_s, nor anything else I could find really ...

We can't completely revert it since we need the attribute number to stay allocated, but that's all we cannot remove.

I'm investigating this and will report back.

#5 lore raw
Quoted 36 lines · Jeff Johnson
Quoted 35 lines · Johannes Berg
Quoted 5 lines · Jeff Johnson
Quoted 5 lines
net/wireless/nl80211.c +0 -0
@@ -911,6 +911,7 @@ nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = {
 	[NL80211_BAND_5GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_6GHZ] = { .type = NLA_S32 },
Quoted 8 lines

net/wireless/nl80211.c nl80211_match_band_rssi_policy[NUM_NL80211_BANDS] = { · line 917

Quoted 5 lines
net/wireless/nl80211.c +1 -0
 	[NL80211_BAND_60GHZ] = { .type = NLA_S32 },
+	[NL80211_BAND_S1GHZ] = { .type = NLA_S32 },
 	[NL80211_BAND_LC]    = { .type = NLA_S32 },
 };
 

something is really suspicious since the NL80211_BAND_* enums are *value* enums, not attribute ID enums, and hence they should never be used in an nla_policy.

Yeah, that's what it looks like first, but then they do get used anyway...

Quoted 2 lines

what is actually using these as attribute IDs, noting that NL80211_BAND_2GHZ == 0 and hence cannot be used as an attribute ID

Ohh. Good catch!

Quoted 2 lines

seems the logic that introduced this policy needs to be revisited.

Let's just remove it?

commit 1e1b11b6a1111cd9e8af1fd6ccda270a9fa3eacf

Author: vamsi krishna <[email protected]>
Date:   Fri Feb 1 18:34:51 2019 +0530

nl80211/cfg80211: Specify band specific min RSSI thresholds with sched scan

Quoted 8 lines
Quoted 6 lines

As far as I can tell nothing is using that in the first place ... Certainly not in the kernel, nor wpa_s, nor anything else I could find really ...

We can't completely revert it since we need the attribute number to stay allocated, but that's all we cannot remove.

I'm investigating this and will report back.

OK, I have investigated this and based upon the investigation this can be removed (except for keeping the now obsolete uapi bits). This was done in preparation for supporting a new Android interface in the out-of-tree Android driver, but that interface was subsequently withdrawn by Google.

Johannes, do you want to handle this? Or should I?

/jeff

maintainer
#6 lore raw
Quoted 8 lines · Jeff Johnson

OK, I have investigated this and based upon the investigation this can be removed (except for keeping the now obsolete uapi bits). This was done in preparation for supporting a new Android interface in the out-of-tree Android driver, but that interface was subsequently withdrawn by Google.

Johannes, do you want to handle this? Or should I?

Would be great if you could send a patch, thanks!

johannes