From patchwork Mon Feb 13 10:55:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Bornand X-Patchwork-Id: 13138265 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3DE9C636D4 for ; Mon, 13 Feb 2023 10:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbjBMKzM (ORCPT ); Mon, 13 Feb 2023 05:55:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbjBMKzL (ORCPT ); Mon, 13 Feb 2023 05:55:11 -0500 Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E6FDBD5 for ; Mon, 13 Feb 2023 02:55:07 -0800 (PST) Date: Mon, 13 Feb 2023 10:55:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemb.ch; s=protonmail; t=1676285704; x=1676544904; bh=hJGEW7a9Y+Lo90p9BgYos2s5IIPNHsJdRYhSO+fYzKA=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=mgOqjeCezZNTRLN7QDR9cXFw7qoiAUXQkl7SgoDvYkhQgIMNgUsm+ynzLGnQffugl Ck2eft9OoazYJxPF1q+7qwLG/qVidWKAqJ2Ptyt7J0+7xfr9GDoJc2fwhhKZAAMpUw 8MJnOlxKjbBWPiQl7/QBQM1/iY5U+faA1hbOB1abiwxIGr5OoR1FaerzmMCEor2rri 9bCuLffNKpeQsHN2f/4F1iI3C6ms/S+R+xe1KV6PvjNxFBn0F+882hE/X7TSxxLq+R KMManUbhRhKgyc/qg2DWGGMeB0CfG7r6JuXulKv/13Fi68ucc/46cAaOqfwhaRqZRG SgEKdCcILkxsA== To: Johannes Berg , linux-wireless@vger.kernel.org From: Marc Bornand Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Valo , Marc Bornand , Yohan Prod'homme , stable@vger.kernel.org Subject: [PATCH v2] Set ssid when authenticating Message-ID: <20230213105436.595245-1-dev.mbornand@systemb.ch> Feedback-ID: 65519157:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org changes since v1: - add some informations - test it on wireless-2023-01-18 tag - no real code change When a connexion was established without going through NL80211_CMD_CONNECT, the ssid was never set in the wireless_dev struct. Now we set it during when an NL80211_CMD_AUTHENTICATE is issued. It may be needed to test this on some additional hardware (tested with iwlwifi and a AX201, and iwd on the userspace side), I could not test things like roaming and p2p. alternatives: 1. Do the same but during association and not authentication. 2. use ieee80211_bss_get_elem in nl80211_send_iface, this would report the right ssid to userspace, but this would not fix the root cause, this alos wa the behavior prior to 7b0a0e3c3a882 when the bug was introduced. This applies to v6.2-rc8 or wireless-2023-01-18, The last linux version known to be unafected is 5.19 and the bug was backported to the 5.19.y releases Reported-by: Yohan Prod'homme Fixes: 7b0a0e3c3a88260b6fcb017e49f198463aa62ed1 Cc: stable@vger.kernel.org Link: https://bugzilla.kernel.org/show_bug.cgi?id=216711 Signed-off-by: Marc Bornand --- net/wireless/nl80211.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.39.1 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 33a82ecab9d5..f1627ea542b9 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -10552,6 +10552,10 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) return -ENOENT; wdev_lock(dev->ieee80211_ptr); + + memcpy(dev->ieee80211_ptr->u.client.ssid, ssid, ssid_len); + dev->ieee80211_ptr->u.client.ssid_len = ssid_len; + err = cfg80211_mlme_auth(rdev, dev, &req); wdev_unlock(dev->ieee80211_ptr); @@ -11025,6 +11029,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info) local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; wdev_lock(dev->ieee80211_ptr); + + if (reason_code == WLAN_REASON_DEAUTH_LEAVING) { + dev->ieee80211_ptr->u.client.ssid_len = 0; + } + err = cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code, local_state_change); wdev_unlock(dev->ieee80211_ptr);