diff mbox series

[wireless-next,v3,2/2] wifi: mac80211: process group addressed Rx data and mgmt packets on intended interface

Message ID 20250523115838.481402-3-maharaja.kennadyrajan@oss.qualcomm.com
State Superseded
Headers show
Series wifi: mac80211: Fix Rx packet handling in multi-radio devices | expand

Commit Message

Maharaja Kennadyrajan May 23, 2025, 11:58 a.m. UTC
Currently, in multi-radio devices, group-addressed data and management
frames received on one band are getting processed on an interface running
on a different band. This occurs because these frames do not have the
destination station information, unlike unicast Rx frame processing where
the transmitting station is known.

There is no check to ensure that the sdata is running on the same band as
the frames are received on before processing those frames.

Fix this by checking the operating frequency of the interface against the
frequency of the packets received before forwarding them to the interface
in multi-radio devices.

The current behavior is retained as a fallback mechanism when the frequency
is not reported by the drivers.

Signed-off-by: Maharaja Kennadyrajan <maharaja.kennadyrajan@oss.qualcomm.com>
---
 net/mac80211/rx.c | 48 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

Comments

kernel test robot June 3, 2025, 2:07 p.m. UTC | #1
Hello,

kernel test robot noticed "hwsim.pasn_kdk_derivation.fail" on:

commit: 9b295898d736daa9f3287430f4bef5481ee0e99c ("[PATCH wireless-next v3 2/2] wifi: mac80211: process group addressed Rx data and mgmt packets on intended interface")
url: https://github.com/intel-lab-lkp/linux/commits/Maharaja-Kennadyrajan/wifi-mac80211-update-ieee80211_rx_status-freq-documentation-for-multi-radio/20250523-195936
patch link: https://lore.kernel.org/all/20250523115838.481402-3-maharaja.kennadyrajan@oss.qualcomm.com/
patch subject: [PATCH wireless-next v3 2/2] wifi: mac80211: process group addressed Rx data and mgmt packets on intended interface

in testcase: hwsim
version: hwsim-x86_64-4b8ac10cb-1_20250525
with following parameters:

	test: pasn_kdk_derivation



config: x86_64-rhel-9.4-func
compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-4790 v3 @ 3.60GHz (Haswell) with 6G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)




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 <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202506032129.39ad1ab-lkp@intel.com

group: group-34, test: pasn_kdk_derivation
2025-05-30 22:20:38 export USER=root
2025-05-30 22:20:38 ./build.sh
Building TNC testing tools
Building wlantest
Building hs20-osu-client
Building hostapd
Building wpa_supplicant
2025-05-30 22:21:27 ./start.sh
2025-05-30 22:21:28 ./run-tests.py pasn_kdk_derivation
DEV: wlan0: 02:00:00:00:00:00
DEV: wlan1: 02:00:00:00:01:00
DEV: wlan2: 02:00:00:00:02:00
APDEV: wlan3
APDEV: wlan4
START pasn_kdk_derivation 1/1
Test: PASN authentication with forced KDK derivation
Starting AP wlan3
Starting AP wlan4
PASN: unexpected status
Traceback (most recent call last):
  File "/lkp/benchmarks/hwsim/tests/hwsim/./run-tests.py", line 591, in main
    t(dev, apdev)
  File "/lkp/benchmarks/hwsim/tests/hwsim/test_pasn.py", line 925, in test_pasn_kdk_derivation
    check_pasn_akmp_cipher(dev[0], hapd0, "PASN", "CCMP")
  File "/lkp/benchmarks/hwsim/tests/hwsim/test_pasn.py", line 122, in check_pasn_akmp_cipher
    raise Exception("PASN: unexpected status")
Exception: PASN: unexpected status
FAIL pasn_kdk_derivation 3.876573 2025-05-30 22:21:33.773779
passed 0 test case(s)
skipped 0 test case(s)
failed tests: pasn_kdk_derivation
2025-05-30 22:21:33 ./stop.sh



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250603/202506032129.39ad1ab-lkp@intel.com
diff mbox series

Patch

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 09beb65d6108..59028c08dd52 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5125,6 +5125,30 @@  static bool ieee80211_rx_for_interface(struct ieee80211_rx_data *rx,
 	return ieee80211_prepare_and_rx_handle(rx, skb, consume);
 }
 
+static bool
+ieee80211_rx_is_sdata_match(struct ieee80211_sub_if_data *sdata,
+			    int freq)
+{
+	struct ieee80211_link_data *link;
+	struct ieee80211_bss_conf *bss_conf;
+	struct ieee80211_chanctx_conf *conf;
+
+	if (!freq)
+		return true;
+
+	for_each_link_data(sdata, link) {
+		bss_conf = link->conf;
+		if (!bss_conf)
+			continue;
+		conf = rcu_dereference(bss_conf->chanctx_conf);
+		if (conf && conf->def.chan &&
+		    conf->def.chan->center_freq == freq)
+			return true;
+	}
+
+	return false;
+}
+
 /*
  * This is the actual Rx frames handler. as it belongs to Rx path it must
  * be called with rcu_read_lock protection.
@@ -5264,18 +5288,26 @@  static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
 		 * the loop to avoid copying the SKB once too much
 		 */
 
-		if (!prev) {
-			prev = sdata;
-			continue;
-		}
+		/* Process the group addressed management and data packets
+		 * in the intended interface when the operating frequency
+		 * matches with rx_status->freq in multi-radio devices.
+		 * If rx_status->freq is not set by the driver, then
+		 * follow the existing code flow.
+		 */
 
-		rx.sdata = prev;
-		ieee80211_rx_for_interface(&rx, skb, false);
+		if (ieee80211_rx_is_sdata_match(sdata, status->freq)) {
+			if (!prev) {
+				prev = sdata;
+				continue;
+			}
 
-		prev = sdata;
+			rx.sdata = prev;
+			ieee80211_rx_for_interface(&rx, skb, false);
+			prev = sdata;
+		}
 	}
 
-	if (prev) {
+	if (prev && ieee80211_rx_is_sdata_match(prev, status->freq)) {
 		rx.sdata = prev;
 
 		if (ieee80211_rx_for_interface(&rx, skb, true))