Skip to contentSkip to conversation

Fix: Ensure auth_data and ap_addr are properly set before marking STA as authenticated

PATCH In review Saru2003 3 participants 4 messages Nov 8, 2024

Subsystems (3)
lore
Share & tools
lore

Saru2003

author
#0 lore raw

PATCH 1/1 Fix: Ensure auth_data and ap_addr are properly set before marking STA as authenticated

---
 net/mac80211/mlme.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +9 -2
index 735e78adb0db..a1ca7385dc1b 100644
@@ -4247,8 +4247,15 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
 static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-	const u8 *ap_addr = ifmgd->auth_data->ap_addr;
+	const u8 *ap_addr;
 	struct sta_info *sta;
+	
+	if (!ifmgd->auth_data || !ifmgd->auth_data->ap_addr) {
+		sdata_info(sdata, "auth_data not set or ap_addr missing\n");
+		return false;
+	}
+
+	ap_addr = ifmgd->auth_data->ap_addr;
 
 	lockdep_assert_wiphy(sdata->local->hw.wiphy);
 
@@ -4261,7 +4268,7 @@ static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
 	/* move station state to auth */
 	sta = sta_info_get(sdata, ap_addr);
 	if (!sta) {
-		WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr);
+	        sdata_info(sdata, "STA %pM not found, skipping authentication mark\n", ap_addr);
 		return false;
 	}
 	if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) {
Signature · 1 line
2.43.0
maintainer
#1 lore raw

net/mac80211/mlme.c static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, · line 4253

Quoted 11 lines · On Fri, 2024-11-08 at 07:58 +0530, Saru2003 wrote:

+++ b/net/mac80211/mlme.c

net/mac80211/mlme.c +3 -1
@@ -4247,8 +4247,15 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
 static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-	const u8 *ap_addr = ifmgd->auth_data->ap_addr;
+	const u8 *ap_addr;
 	struct sta_info *sta;
+	
+	if (!ifmgd->auth_data ||

That's ridiculous. By the argument behind this we could add probably hundreds of such checks all over the place.

Review static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, · line 4254

Quoted 1 line
(quoted diff) +0 -0
 !ifmgd->auth_data->ap_addr) {

and that's even a compiler warning.

net/mac80211/mlme.c static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata) · line 4272

Quoted 5 lines
net/mac80211/mlme.c +1 -1
 	sta = sta_info_get(sdata, ap_addr);
 	if (!sta) {
-		WARN_ONCE(1, "%s: STA %pM not found", sdata->name, ap_addr);
+	        sdata_info(sdata, "STA %pM not found, skipping authentication mark\n", ap_addr);
 		return false;

That's also wrong, it doesn't just skip that part.

johannes

#2 lore raw
In reply to Saru2003
kernel test robot noticed the following build warnings:

Hi Saru2003,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.12-rc6 next-20241107] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saru2003/Fix-Ensure-auth_data-and-ap_addr-are-properly-set-before-marking-STA-as-authenticated/20241108-103338
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20241108022828.6571-1-sarvesh20123%40gmail.com
patch subject: [PATCH] Fix: Ensure auth_data and ap_addr are properly set before marking STA as authenticated
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241108/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241108/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

net/mac80211/mlme.c: In function 'ieee80211_mark_sta_auth':

>> net/mac80211/mlme.c:4341:34: warning: the comparison will always evaluate as 'true' for the address of 'ap_addr' will never be NULL [-Waddress]
    4341 |         if (!ifmgd->auth_data || !ifmgd->auth_data->ap_addr) {
         |                                  ^
   In file included from net/mac80211/mlme.c:28:
   net/mac80211/ieee80211_i.h:414:12: note: 'ap_addr' declared here
     414 |         u8 ap_addr[ETH_ALEN] __aligned(2);
         |            ^~~~~~~

vim +4341 net/mac80211/mlme.c

4334
4335 static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
4336 {
4337 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4338 const u8 *ap_addr;
4339 struct sta_info *sta;
4340

> 4341		if (!ifmgd->auth_data || !ifmgd->auth_data->ap_addr) {

4342 sdata_info(sdata, "auth_data not set or ap_addr missing\n");
4343 return false;
4344 }
4345
4346 ap_addr = ifmgd->auth_data->ap_addr;
4347
4348 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4349
4350 sdata_info(sdata, "authenticated\n");
4351 ifmgd->auth_data->done = true;
4352 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
4353 ifmgd->auth_data->timeout_started = true;
4354 run_again(sdata, ifmgd->auth_data->timeout);
4355
4356 /* move station state to auth */
4357 sta = sta_info_get(sdata, ap_addr);
4358 if (!sta) {
4359 sdata_info(sdata, "STA %pM not found, skipping authentication mark\n", ap_addr);
4360 return false;
4361 }
4362 if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) {
4363 sdata_info(sdata, "failed moving %pM to auth\n", ap_addr);
4364 return false;
4365 }
4366
4367 return true;
4368 }
4369

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to Saru2003
kernel test robot noticed the following build warnings:

Hi Saru2003,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.12-rc6 next-20241107] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saru2003/Fix-Ensure-auth_data-and-ap_addr-are-properly-set-before-marking-STA-as-authenticated/20241108-103338
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20241108022828.6571-1-sarvesh20123%40gmail.com
patch subject: [PATCH] Fix: Ensure auth_data and ap_addr are properly set before marking STA as authenticated
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20241108/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241108/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from net/mac80211/mlme.c:16:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> net/mac80211/mlme.c:4341:46: warning: address of array 'ifmgd->auth_data->ap_addr' will always evaluate to 'true' [-Wpointer-bool-conversion]
    4341 |         if (!ifmgd->auth_data || !ifmgd->auth_data->ap_addr) {
         |                                  ~~~~~~~~~~~~~~~~~~~^~~~~~~

5 warnings generated.

vim +4341 net/mac80211/mlme.c

4334
4335 static bool ieee80211_mark_sta_auth(struct ieee80211_sub_if_data *sdata)
4336 {
4337 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4338 const u8 *ap_addr;
4339 struct sta_info *sta;
4340

> 4341		if (!ifmgd->auth_data || !ifmgd->auth_data->ap_addr) {

4342 sdata_info(sdata, "auth_data not set or ap_addr missing\n");
4343 return false;
4344 }
4345
4346 ap_addr = ifmgd->auth_data->ap_addr;
4347
4348 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4349
4350 sdata_info(sdata, "authenticated\n");
4351 ifmgd->auth_data->done = true;
4352 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
4353 ifmgd->auth_data->timeout_started = true;
4354 run_again(sdata, ifmgd->auth_data->timeout);
4355
4356 /* move station state to auth */
4357 sta = sta_info_get(sdata, ap_addr);
4358 if (!sta) {
4359 sdata_info(sdata, "STA %pM not found, skipping authentication mark\n", ap_addr);
4360 return false;
4361 }
4362 if (sta_info_move_state(sta, IEEE80211_STA_AUTH)) {
4363 sdata_info(sdata, "failed moving %pM to auth\n", ap_addr);
4364 return false;
4365 }
4366
4367 return true;
4368 }
4369

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki