From: Slawomir Stepien <sst@poczta.fm>
To: syzkaller-bugs@googlegroups.com, johannes@sipsolutions.net,
linux-wireless@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, syzbot@lists.linux.dev,
sst@poczta.fm,
syzbot+9bdc0c5998ab45b05030@syzkaller.appspotmail.com
Subject: [PATCH 2/3] wifi: cfg80211: move link_id validation earlier in nl80211_new_station()
Date: Thu, 13 Aug 2026 11:04:33 +0200 [thread overview]
Message-ID: <20260813090434.2071318-2-sst@poczta.fm> (raw)
In-Reply-To: <20260813090434.2071318-1-sst@poczta.fm>
I do not see a reason why this check is so low in the function. Move it
up right next to param fetch.
This new position is more beneficial for AP/Link state check that will
be added in upcoming commit.
Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
net/wireless/nl80211.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0c4e6bd6a44c..ebde52655904 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9222,6 +9222,16 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
params.link_sta_params.link_id =
nl80211_link_id_or_invalid(info->attrs);
+ if (wdev->valid_links) {
+ if (params.link_sta_params.link_id < 0)
+ return -EINVAL;
+ if (!(wdev->valid_links & BIT(params.link_sta_params.link_id)))
+ return -ENOLINK;
+ } else {
+ if (params.link_sta_params.link_id >= 0)
+ return -EINVAL;
+ }
+
if (info->attrs[NL80211_ATTR_MLD_ADDR]) {
mac_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]);
params.link_sta_params.mld_mac = mac_addr;
@@ -9494,27 +9504,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
/* be aware of params.vlan when changing code here */
- if (wdev->valid_links) {
- if (params.link_sta_params.link_id < 0) {
- err = -EINVAL;
- goto out;
- }
- if (!(wdev->valid_links & BIT(params.link_sta_params.link_id))) {
- err = -ENOLINK;
- goto out;
- }
- } else {
- if (params.link_sta_params.link_id >= 0) {
- err = -EINVAL;
- goto out;
- }
- }
-
params.epp_peer =
nla_get_flag(info->attrs[NL80211_ATTR_EPP_PEER]);
err = rdev_add_station(rdev, wdev, mac_addr, ¶ms);
-out:
dev_put(params.vlan);
return err;
}
--
2.55.0
next prev parent reply other threads:[~2026-08-13 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 9:04 [PATCH 1/3] wifi: cfg80211: do not support direct add of station to AP_VLAN interfaces Slawomir Stepien
2026-08-13 9:04 ` Slawomir Stepien [this message]
2026-08-13 9:04 ` [PATCH 3/3] wifi: cfg80211: check if AP has been started before adding new station Slawomir Stepien
2026-09-04 9:25 ` Johannes Berg
2026-09-07 9:46 ` Slawomir Stepien
2026-09-07 9:47 ` Johannes Berg
2026-09-08 9:44 ` Slawomir Stepien
2026-09-08 9:46 ` Johannes Berg
2026-09-08 11:59 ` Slawomir Stepien
2026-09-08 12:25 ` Johannes Berg
2026-09-08 13:35 ` Slawomir Stepien
2026-09-08 13:37 ` Johannes Berg
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=20260813090434.2071318-2-sst@poczta.fm \
--to=sst@poczta.fm \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=syzbot+9bdc0c5998ab45b05030@syzkaller.appspotmail.com \
--cc=syzbot@lists.linux.dev \
--cc=syzkaller-bugs@googlegroups.com \
/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