linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Johannes Berg <johannes.berg@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 04/16] wifi: mac80211: mlme: fix non-inheritence element
Date: Sun,  4 Jun 2023 12:11:16 +0300	[thread overview]
Message-ID: <20230604120651.3addaa5c4782.If3a78f9305997ad7ef4ba7ffc17a8234c956f613@changeid> (raw)
In-Reply-To: <20230604091128.609335-1-gregory.greenman@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

There were two bugs when creating the non-inheritence
element:
 1) 'at_extension' needs to be declared outside the loop,
    otherwise the value resets every iteration and we
    can never really switch properly
 2) 'added' never got set to true, so we always cut off
    the extension element again at the end of the function

This shows another issue that we might add a list but no
extension list, but we need to make the extension list a
zero-length one in that case.

Fix all these issues. While at it, add a comment explaining
the trim.

Fixes: 81151ce462e5 ("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 net/mac80211/mlme.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 4ea383aafcac..97671734427c 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1217,6 +1217,7 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
 					       const u16 *inner)
 {
 	unsigned int skb_len = skb->len;
+	bool at_extension = false;
 	bool added = false;
 	int i, j;
 	u8 *len, *list_len = NULL;
@@ -1228,7 +1229,6 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
 	for (i = 0; i < PRESENT_ELEMS_MAX && outer[i]; i++) {
 		u16 elem = outer[i];
 		bool have_inner = false;
-		bool at_extension = false;
 
 		/* should at least be sorted in the sense of normal -> ext */
 		WARN_ON(at_extension && elem < PRESENT_ELEM_EXT_OFFS);
@@ -1257,8 +1257,14 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb,
 		}
 		*list_len += 1;
 		skb_put_u8(skb, (u8)elem);
+		added = true;
 	}
 
+	/* if we added a list but no extension list, make a zero-len one */
+	if (added && (!at_extension || !list_len))
+		skb_put_u8(skb, 0);
+
+	/* if nothing added remove extension element completely */
 	if (!added)
 		skb_trim(skb, skb_len);
 	else
-- 
2.38.1


  parent reply	other threads:[~2023-06-04  9:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-04  9:11 [PATCH 00/16] cfg80211/mac80211 patches from our internal tree 2023-06-04 gregory.greenman
2023-06-04  9:11 ` [PATCH 01/16] wifi: mac80211: use u64 to hold enum ieee80211_bss_change flags gregory.greenman
2023-06-04  9:11 ` [PATCH 02/16] wifi: mac80211: refactor ieee80211_select_link_key() gregory.greenman
2023-06-04  9:11 ` [PATCH 03/16] wifi: mac80211: don't translate beacon/presp addrs gregory.greenman
2023-06-04  9:11 ` gregory.greenman [this message]
2023-06-04  9:11 ` [PATCH 05/16] wifi: mac80211: provide a helper to fetch the medium synchronization delay gregory.greenman
2023-06-04  9:11 ` [PATCH 06/16] wifi: cfg80211: reject bad AP MLD address gregory.greenman
2023-06-04  9:11 ` [PATCH 07/16] wifi: mac80211_hwsim: check the return value of nla_put_u32 gregory.greenman
2023-06-04  9:11 ` [PATCH 08/16] wifi: mac80211: recalc min chandef for new STA links gregory.greenman
2023-06-04  9:11 ` [PATCH 09/16] wifi: mac80211: move sta_info_move_state() up gregory.greenman
2023-06-04  9:11 ` [PATCH 10/16] wifi: mac80211: batch recalc during STA flush gregory.greenman
2023-06-04  9:11 ` [PATCH 11/16] wifi: mac80211: use correct iftype HE cap gregory.greenman
2023-06-04  9:11 ` [PATCH 12/16] wifi: mac80211: add helpers to access sband iftype data gregory.greenman
2023-06-04  9:11 ` [PATCH 13/16] wifi: mac80211: remove typecast in a call to ieee80211_config_bw() gregory.greenman
2023-06-06 13:18   ` Nicolas Escande
2023-06-06 13:22     ` Johannes Berg
2023-06-04  9:11 ` [PATCH 14/16] wifi: mac80211: Modify type of "changed" variable gregory.greenman
2023-12-02 17:56   ` Jeff Johnson
2023-12-03 16:48     ` Jeff Johnson
2023-12-03 18:42       ` Johannes Berg
2023-06-04  9:11 ` [PATCH 15/16] wifi: mac80211_hwsim: Fix possible NULL dereference gregory.greenman
2023-06-04  9:11 ` [PATCH 16/16] wifi: mac80211: stop warning after reconfig failures gregory.greenman

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=20230604120651.3addaa5c4782.If3a78f9305997ad7ef4ba7ffc17a8234c956f613@changeid \
    --to=gregory.greenman@intel.com \
    --cc=johannes.berg@intel.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;
as well as URLs for NNTP newsgroup(s).