From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387910; b=VV5Pz8/qQ+RZpajDH+fuVGlppA7xfouPaJTrGZHTfuZhEw1sRtkO1tpM0KaXx56MZNoY uFAUO/CJT/pKshKzt37UXMJe12H88mtclWmhCuLzSlOjes4ywnEMyP3fRJRFefalVA5X1 R7eSbZbKHhjxeVtrDiiuxpNYKXFXBpxzE9LOXWQnY6IH6089GxGmsaS6UwRmxSYz9SUTB 6dEyvPx7iyjCiHyBEe0lUp/kJwsQY+BeYmSXKOaEaXadSqyRL7SfjhB6pjc5XuPD3XH1r sTKnI5IC054s+/ew/7HDo6W8tYvXUel4K+S5lyj5m24NyzJQJZuAtci3Fod7wfFN6lQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387910; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=dieutcuRioedFzJO2xni+RKtQUJBdJjEhTqDzcjgXiw=; b=gcA3jy8JRxvUmUtcaD3ZlAtJVuwvjDbl1lqEndoP7Xw9riiIEgAFHiEu6/w7UOBxy25q szCLxKIqIrw/GCMirsGpoRLjgI0dE8sQZudU3rwIDT7FDRCpPYbIugV9jRKDrRdnTnann NzkXZVmZzM0MhUkZccAG0rxLPDqblZgzgPLUYtDNgBdyZxiCf1t1233IplhFRfZwu9keg y/7QDcH/GO600TSmM+b7mFSmlmcBhOc49hMyh31JAu9e4mFfzbxIViGc5mxz7QgHVLmlh xfP9Nub4XxKXmwkgsAFqkMOWC7xMLl9dcw7K6PKUUekjvxopFdlMy9O1NSiTYwpDshA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aKabd9FY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4CE0606A322; Fri, 4 Dec 2026 12:38:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aKabd9FY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 301B41F000C2; Fri, 4 Dec 2026 12:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387910; bh=dieutcuRioedFzJO2xni+RKtQUJBdJjEhTqDzcjgXiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aKabd9FYp1AXzSJrKdP+XYydWT5Zvj38r2WQ4OWPnQ+CyejG6U8CglqTuohZGP8Pu ly8ZlYUp5nn+bx0Zm8MmrMwGKhX1Od2YMQc7bepU7wLcKAgW2QYvL1+GU9Pa5i9tPj HKeiLdp8qfEsK73vlcAnoHVhgUu1PQKctPu7raLw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Berg , Sasha Levin Subject: [PATCH 6.1 0367/1059] wifi: mac80211: fix mbssid/rnr allocation in beacon data Date: Fri, 4 Dec 2026 18:58:18 +0900 Message-ID: <20261204100653.783849268@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Berg [ Upstream commit baf0d4feed2f0fed8e045f948534a4bd43ae464e ] These structs are placed after the tail, but that can make them unaligned. Change the order so the structs are after one another, and then followed by the head/tail/elements. Assisted-by: LLM Fixes: 2b3171c6fe0a ("mac80211: MBSSID beacon handling in AP mode") Link: https://patch.msgid.link/20261005224950.2f554b2c7c10.Ie961eb6b1435f956446e052936258758b966c67f@changeid Signed-off-by: Johannes Berg [ sashal: Adjusted declarations to keep u32 changed and add u8 *pos, and dropped the old && guard in the old-RNR lookup since the patch moves it into the old->mbssid_ies branch. ] Signed-off-by: Sasha Levin --- net/mac80211/cfg.c | 53 +++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 16bd28290ae68..216e49359b9a1 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1120,6 +1120,7 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, struct beacon_data *new, *old; int new_head_len, new_tail_len; int size, err; + u8 *pos; u32 changed = BSS_CHANGED_BEACON; struct ieee80211_bss_conf *link_conf = link->conf; @@ -1147,20 +1148,16 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, /* new or old multiple BSSID elements? */ if (params->mbssid_ies) { mbssid = params->mbssid_ies; - size += struct_size(new->mbssid_ies, elem, mbssid->cnt); - if (params->rnr_ies) { - rnr = params->rnr_ies; - size += struct_size(new->rnr_ies, elem, rnr->cnt); - } - size += ieee80211_get_mbssid_beacon_len(mbssid, rnr, - mbssid->cnt); + rnr = params->rnr_ies; } else if (old && old->mbssid_ies) { mbssid = old->mbssid_ies; + rnr = old->rnr_ies; + } + + if (mbssid) { size += struct_size(new->mbssid_ies, elem, mbssid->cnt); - if (old && old->rnr_ies) { - rnr = old->rnr_ies; + if (rnr) size += struct_size(new->rnr_ies, elem, rnr->cnt); - } size += ieee80211_get_mbssid_beacon_len(mbssid, rnr, mbssid->cnt); } @@ -1172,26 +1169,38 @@ static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, /* start filling the new info now */ /* - * pointers go into the block we allocated, - * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies + * pointers go into the block we allocated, the order in memory is + * - struct beacon_data + * - struct mbssid_ies (including variable array) + * - struct rnr_ies (including variable array) + * - beacon head + * - beacon tail + * - mbssid/rnr elements + * so that the structs (which contain pointers) are all aligned */ - new->head = ((u8 *) new) + sizeof(*new); - new->tail = new->head + new_head_len; - new->head_len = new_head_len; - new->tail_len = new_tail_len; - /* copy in optional mbssid_ies */ + pos = (u8 *)(new + 1); if (mbssid) { - u8 *pos = new->tail + new->tail_len; - new->mbssid_ies = (void *)pos; pos += struct_size(new->mbssid_ies, elem, mbssid->cnt); - pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies, - mbssid); if (rnr) { new->rnr_ies = (void *)pos; pos += struct_size(new->rnr_ies, elem, rnr->cnt); - ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr); } + } + + new->head = pos; + new->head_len = new_head_len; + pos += new_head_len; + new->tail = pos; + new->tail_len = new_tail_len; + pos += new_tail_len; + + /* copy in optional mbssid_ies */ + if (mbssid) { + pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies, + mbssid); + if (rnr) + ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr); /* update bssid_indicator */ link_conf->bssid_indicator = ilog2(__roundup_pow_of_two(mbssid->cnt + 1)); -- 2.53.0