netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Set ssid when authenticating
@ 2023-02-13 21:05 Marc Bornand
  2023-02-14 12:54 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Bornand @ 2023-02-13 21:05 UTC (permalink / raw)
  To: Johannes Berg, linux-wireless
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, linux-kernel, Kalle Valo, Marc Bornand,
	Yohan Prod'homme, stable

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 <kernel@zoddo.fr>
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 <dev.mbornand@systemb.ch>
---
 net/wireless/sme.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 4b5b6ee0fe01..629d7b5f65c1 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,21 @@ 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->datalen == 0)
+				continue;
+
+			memcpy(wdev->u.client.ssid, ssid->data, ssid->datalen);
+			wdev->u.client.ssid_len = ssid->datalen;
+		}
+		rcu_read_unlock();
+	}
+
 	return;
 out:
 	for_each_valid_link(cr, link)
--
2.39.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] Set ssid when authenticating
  2023-02-13 21:05 [PATCH v3] Set ssid when authenticating Marc Bornand
@ 2023-02-14 12:54 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2023-02-14 12:54 UTC (permalink / raw)
  To: Marc Bornand, linux-wireless
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, linux-kernel, Kalle Valo, Yohan Prod'homme, stable

Hi,

Please provide a proper subject/commit message for this. The
"authenticating" is no longer true anyway.

See
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages

On Mon, 2023-02-13 at 21:05 +0000, Marc Bornand wrote:
> 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

connection

> 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 <kernel@zoddo.fr>
> 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 <dev.mbornand@systemb.ch>
> ---
>  net/wireless/sme.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/net/wireless/sme.c b/net/wireless/sme.c
> index 4b5b6ee0fe01..629d7b5f65c1 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,21 @@ 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->datalen == 0)

need to check also that it exists

> +				continue;
> +
> +			memcpy(wdev->u.client.ssid, ssid->data, ssid->datalen);
> +			wdev->u.client.ssid_len = ssid->datalen;

you can break here.

johannes

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-14 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-13 21:05 [PATCH v3] Set ssid when authenticating Marc Bornand
2023-02-14 12:54 ` Johannes Berg

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).