Skip to contentSkip to conversation

wifi: wireless: Fix bad memory passed in inform_single_bss_data.

PATCH In review [email protected] 2 participants 3 messages Oct 21, 2023 – Oct 22, 2023 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: wireless: Fix bad memory passed in inform_single_bss_data.

From: Ben Greear <[email protected]>

The sins of similar variable names and passing void pointers are seen again in wireless-next tree.

Wrong data was passed into the rdev_inform_bss method causing crashes.

---
 net/wireless/scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/scan.c +1 -1
index 7f8e831ef1dc..52b048675cc7 100644
@@ -2155,7 +2155,7 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
 	if (!res)
 		goto drop;
 
-	rdev_inform_bss(rdev, &res->pub, ies, data->drv_data);
+	rdev_inform_bss(rdev, &res->pub, ies, drv_data->drv_data);
 
 	if (data->bss_source == BSS_SOURCE_MBSSID) {
 		/* this is a nontransmitting bss, we need to add it to
Signature · 1 line
2.40.0
#1 lore raw
Quoted 9 lines · On Sat, 21 Oct 2023 at 16:52, <[email protected]> wrote:

From: Ben Greear <[email protected]>

The sins of similar variable names and passing void pointers are seen again in wireless-next tree.

Wrong data was passed into the rdev_inform_bss method causing crashes.

Is there any good reason for the void pointers?
The patch you propose fixes the immediate problem, but if the void pointers were replaced with struct pointers, the compiler could catch this sort of problem.
I imagine there could be similar confusion with this struct and function having the same name:
0 scan.c 1999 struct cfg80211_inform_single_bss_data {
1 scan.c 2023 cfg80211_inform_single_bss_data(struct wiphy *wiphy,

Maybe renaming the following:
struct cfg80211_inform_bss *drv_data = data->drv_data; to
struct cfg80211_inform_bss *c_inform_bss1 = data->drv_data; would reduce the confusion.

author
#2 lore raw
Quoted 20 lines · James Dutton
Quoted 9 lines · On Sat, 21 Oct 2023 at 16:52, <[email protected]> wrote:

From: Ben Greear <[email protected]>

The sins of similar variable names and passing void pointers are seen again in wireless-next tree.

Wrong data was passed into the rdev_inform_bss method causing crashes.

Is there any good reason for the void pointers?
The patch you propose fixes the immediate problem, but if the void pointers were replaced with struct pointers, the compiler could catch this sort of problem.
I imagine there could be similar confusion with this struct and function having the same name:
0 scan.c 1999 struct cfg80211_inform_single_bss_data {
1 scan.c 2023 cfg80211_inform_single_bss_data(struct wiphy *wiphy,

Quoted 5 lines

Maybe renaming the following:
struct cfg80211_inform_bss *drv_data = data->drv_data; to
struct cfg80211_inform_bss *c_inform_bss1 = data->drv_data; would reduce the confusion.

It takes a lot of time and patience to get more complicated patches upstreamed, so maybe someone else has interested in pursuing that.

Probably a somewhat generic call-back struct could be used to pass info back to the mac80211 stack instead of using the void*, but that would require touching a larger set of drivers most likely.

I am tracking down more crash bugs in the mean time.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com