From patchwork Tue Feb 14 13:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Bornand X-Patchwork-Id: 13140036 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 45DA9C61DA4 for ; Tue, 14 Feb 2023 13:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232589AbjBNNVF (ORCPT ); Tue, 14 Feb 2023 08:21:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbjBNNVC (ORCPT ); Tue, 14 Feb 2023 08:21:02 -0500 Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5F926CC0; Tue, 14 Feb 2023 05:20:37 -0800 (PST) Date: Tue, 14 Feb 2023 13:20:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemb.ch; s=protonmail; t=1676380835; x=1676640035; bh=8AmFFgy2lxaoStl2yp+jrbUYg5WYi0q0Y7u85UwNb/k=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=E8kSsNtIs9RQ3hhAxa8EyurMI5sarsZ8BZTc/GByT0yYhjS7s2OTiv4/4KIuGSO8H UyByh/MqTbJ3i0F1Ay9Qyr8TK45QnOmDwfd/4oHRCTFo+fplUGnKSopHe2AmNX4rPe MRF1Ga49FB6uSbzwgBRJdE5cwZE6yTyMZRXiyYc1le20PTbrpqvZIrXPIXgJIiZD7F YGv1Pm7qv/+V7mrovP8MmclXUsufCu0ZFX3pDjgKdnbt7dU9RjrxKV+oh8FlNz5AEO Gpz31u9nx4WzRs1J18zC54iGtZMyFdIBJsjRIY6NR5MMUyVaOWQmFqTUiOlqdDmgK2 brccMsfBRSi2w== 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 v4] Set ssid when authenticating Message-ID: <20230214132009.1011452-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 v3: - add missing NULL check - add missing break changes since v2: - The code was tottaly rewritten based on the disscution of the v2 patch. - the ssid is set in __cfg80211_connect_result() and only if the ssid is not already set. - Do not add an other ssid reset path since it is already done in __cfg80211_disconnected() 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 in __cfg80211_connect_result() when it is not already set. Reported-by: Yohan Prod'homme Fixes: 7b0a0e3c3a88260b6fcb017e49f198463aa62ed1 Cc: linux-wireless@vger.kernel.org Cc: stable@vger.kernel.org Link: https://bugzilla.kernel.org/show_bug.cgi?id=216711 Signed-off-by: Marc Bornand --- net/wireless/sme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.39.1 diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 4b5b6ee0fe01..b552d6c20a26 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -723,6 +723,7 @@ void __cfg80211_connect_result(struct net_device *dev, bool wextev) { struct wireless_dev *wdev = dev->ieee80211_ptr; + const struct element *ssid; const struct element *country_elem = NULL; const u8 *country_data; u8 country_datalen; @@ -883,6 +884,22 @@ void __cfg80211_connect_result(struct net_device *dev, country_data, country_datalen); kfree(country_data); + if (wdev->u.client.ssid_len == 0) { + rcu_read_lock(); + for_each_valid_link(cr, link) { + ssid = ieee80211_bss_get_elem(cr->links[link].bss, + WLAN_EID_SSID); + + if (!ssid || ssid->datalen == 0) + continue; + + memcpy(wdev->u.client.ssid, ssid->data, ssid->datalen); + wdev->u.client.ssid_len = ssid->datalen; + break; + } + rcu_read_unlock(); + } + return; out: for_each_valid_link(cr, link)