Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ho Jie Feng <hjf3108@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, Ho Jie Feng <hjf3108@gmail.com>
Subject: [PATCH wireless] wifi: mac80211: copy the operation elements in cfg80211_beacon_dup()
Date: Mon, 30 Nov 2026 00:48:32 +0800	[thread overview]
Message-ID: <20261129164832.65959-1-hjf3108@gmail.com> (raw)

For a copy made by cfg80211_beacon_dup(), such as during a channel
switch, the *_oper pointers are not copied over, even though the tail
is. Therefore, ieee80211_calc_ap_he_and_lower() finds no operation
element and returns 20 MHz, which is inaccurate. It stays there until
the next beacon is received, then it is parsed again and corrected.

Driver's own rate control or minstrel_ht can run between updates, so
it started over at 20 MHz and again at 80 MHz.

Point the four pointers of the copy at the same offsets in the copy's
tail.

Fixes: c9b62ab79133 ("wifi: mac80211: fix per-station PHY capability bandwidth")
Fixes: 14b1a85518a1 ("wifi: mac80211: AP: handle DBE for clients")
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
 net/mac80211/cfg.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9d7c03b6a6..34e5f1764b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -12,6 +12,7 @@
 #include <linux/nl80211.h>
 #include <linux/rtnetlink.h>
 #include <linux/slab.h>
+#include <linux/util_macros.h>
 #include <net/net_namespace.h>
 #include <linux/rcupdate.h>
 #include <linux/fips.h>
@@ -4601,6 +4602,17 @@ static void ieee80211_end_cac(struct wiphy *wiphy,
 	}
 }
 
+static const void *
+ieee80211_beacon_dup_tail_elem(const struct cfg80211_beacon_data *beacon,
+			       const struct cfg80211_beacon_data *new_beacon,
+			       const void *elem)
+{
+	const u8 *pos = elem;
+
+	/* nl80211 guarantees it is a valid offset into the source tail */
+	return PTR_IF(pos, new_beacon->tail + (pos - beacon->tail));
+}
+
 static struct cfg80211_beacon_data *
 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
 {
@@ -4654,6 +4666,19 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
 		new_beacon->tail = pos;
 		memcpy(pos, beacon->tail, beacon->tail_len);
 		pos += beacon->tail_len;
+
+		new_beacon->ht_oper =
+			ieee80211_beacon_dup_tail_elem(beacon, new_beacon,
+						       beacon->ht_oper);
+		new_beacon->vht_oper =
+			ieee80211_beacon_dup_tail_elem(beacon, new_beacon,
+						       beacon->vht_oper);
+		new_beacon->he_oper =
+			ieee80211_beacon_dup_tail_elem(beacon, new_beacon,
+						       beacon->he_oper);
+		new_beacon->eht_oper =
+			ieee80211_beacon_dup_tail_elem(beacon, new_beacon,
+						       beacon->eht_oper);
 	}
 	if (beacon->beacon_ies_len) {
 		new_beacon->beacon_ies_len = beacon->beacon_ies_len;
-- 
2.53.0


                 reply	other threads:[~2026-11-29 16:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129164832.65959-1-hjf3108@gmail.com \
    --to=hjf3108@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox