linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] wcn36xx: Fix WEP104 encryption type
@ 2018-05-28 11:29 Loic Poulain
  2018-05-28 11:29 ` [PATCH 2/3] wcn36xx: Track associated stations Loic Poulain
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Loic Poulain @ 2018-05-28 11:29 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, linux-arm-msm, Loic Poulain

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index aeb5e6e..4648a78 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -512,7 +512,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
 		break;
 	case WLAN_CIPHER_SUITE_WEP104:
-		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
+		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP104;
 		break;
 	case WLAN_CIPHER_SUITE_CCMP:
 		vif_priv->encrypt_type = WCN36XX_HAL_ED_CCMP;
-- 
2.7.4

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

* [PATCH 2/3] wcn36xx: Track associated stations
  2018-05-28 11:29 [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Loic Poulain
@ 2018-05-28 11:29 ` Loic Poulain
  2018-05-28 11:29 ` [PATCH 3/3] wcn36xx: Fix WEP encryption Loic Poulain
  2018-06-14 14:24 ` [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Loic Poulain @ 2018-05-28 11:29 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, linux-arm-msm, Loic Poulain

Add list of associated stations(STA, AP, peer...) per vif.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/main.c    | 5 +++++
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 4648a78..6fd0bf6 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -567,6 +567,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 				key_conf->keyidx,
 				key_conf->keylen,
 				key);
+
 			if ((WLAN_CIPHER_SUITE_WEP40 == key_conf->cipher) ||
 			    (WLAN_CIPHER_SUITE_WEP104 == key_conf->cipher)) {
 				sta_priv->is_data_encrypted = true;
@@ -984,6 +985,7 @@ static int wcn36xx_add_interface(struct ieee80211_hw *hw,
 	mutex_lock(&wcn->conf_mutex);
 
 	vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
+	INIT_LIST_HEAD(&vif_priv->sta_list);
 	list_add(&vif_priv->list, &wcn->vif_list);
 	wcn36xx_smd_add_sta_self(wcn, vif);
 
@@ -1005,6 +1007,8 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
 	spin_lock_init(&sta_priv->ampdu_lock);
 	sta_priv->vif = vif_priv;
+	list_add(&sta_priv->list, &vif_priv->sta_list);
+
 	/*
 	 * For STA mode HW will be configured on BSS_CHANGED_ASSOC because
 	 * at this stage AID is not available yet.
@@ -1032,6 +1036,7 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
 
 	mutex_lock(&wcn->conf_mutex);
 
+	list_del(&sta_priv->list);
 	wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
 	sta_priv->vif = NULL;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index 11e7401..a58f313 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -129,6 +129,8 @@ struct wcn36xx_vif {
 	u8 self_sta_index;
 	u8 self_dpu_desc_index;
 	u8 self_ucast_dpu_sign;
+
+	struct list_head sta_list;
 };
 
 /**
@@ -154,6 +156,7 @@ struct wcn36xx_vif {
  * |______________|_____________|_______________|
  */
 struct wcn36xx_sta {
+	struct list_head list;
 	struct wcn36xx_vif *vif;
 	u16 aid;
 	u16 tid;
-- 
2.7.4

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

* [PATCH 3/3] wcn36xx: Fix WEP encryption
  2018-05-28 11:29 [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Loic Poulain
  2018-05-28 11:29 ` [PATCH 2/3] wcn36xx: Track associated stations Loic Poulain
@ 2018-05-28 11:29 ` Loic Poulain
  2018-06-14 14:28   ` Kalle Valo
  2018-06-14 14:24 ` [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Kalle Valo
  2 siblings, 1 reply; 5+ messages in thread
From: Loic Poulain @ 2018-05-28 11:29 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, linux-arm-msm, Loic Poulain

In case of WEP encryption, driver has to configure shared key for
associated station(s). Note that sta pointer is NULL in case of non
pairwise key, causing NULL pointer dereference with existing code
(sta_priv->is_data_encrypted). Fix this by using associated sta list
instead.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/main.c | 19 +++++++++++--------
 drivers/net/wireless/ath/wcn36xx/smd.c  | 20 ++++++++++++++------
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 6fd0bf6..e38443e 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -493,7 +493,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 {
 	struct wcn36xx *wcn = hw->priv;
 	struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
-	struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
+	struct wcn36xx_sta *sta_priv = sta ? wcn36xx_sta_to_priv(sta) : NULL;
 	int ret = 0;
 	u8 key[WLAN_MAX_KEY_LEN];
 
@@ -570,13 +570,16 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
 			if ((WLAN_CIPHER_SUITE_WEP40 == key_conf->cipher) ||
 			    (WLAN_CIPHER_SUITE_WEP104 == key_conf->cipher)) {
-				sta_priv->is_data_encrypted = true;
-				wcn36xx_smd_set_stakey(wcn,
-					vif_priv->encrypt_type,
-					key_conf->keyidx,
-					key_conf->keylen,
-					key,
-					get_sta_index(vif, sta_priv));
+				list_for_each_entry(sta_priv,
+						    &vif_priv->sta_list, list) {
+					sta_priv->is_data_encrypted = true;
+					wcn36xx_smd_set_stakey(wcn,
+						vif_priv->encrypt_type,
+						key_conf->keyidx,
+						key_conf->keylen,
+						key,
+						get_sta_index(vif, sta_priv));
+				}
 			}
 		}
 		break;
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index b4dadf7..304a86c 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -1708,12 +1708,20 @@ int wcn36xx_smd_set_stakey(struct wcn36xx *wcn,
 	msg_body.set_sta_key_params.sta_index = sta_index;
 	msg_body.set_sta_key_params.enc_type = enc_type;
 
-	msg_body.set_sta_key_params.key[0].id = keyidx;
-	msg_body.set_sta_key_params.key[0].unicast = 1;
-	msg_body.set_sta_key_params.key[0].direction = WCN36XX_HAL_TX_RX;
-	msg_body.set_sta_key_params.key[0].pae_role = 0;
-	msg_body.set_sta_key_params.key[0].length = keylen;
-	memcpy(msg_body.set_sta_key_params.key[0].key, key, keylen);
+	if (enc_type == WCN36XX_HAL_ED_WEP104 ||
+	    enc_type == WCN36XX_HAL_ED_WEP40) {
+		/* Use bss key for wep (static) */
+		msg_body.set_sta_key_params.def_wep_idx = keyidx;
+		msg_body.set_sta_key_params.wep_type = 0;
+	} else {
+		msg_body.set_sta_key_params.key[0].id = keyidx;
+		msg_body.set_sta_key_params.key[0].unicast = 1;
+		msg_body.set_sta_key_params.key[0].direction = WCN36XX_HAL_TX_RX;
+		msg_body.set_sta_key_params.key[0].pae_role = 0;
+		msg_body.set_sta_key_params.key[0].length = keylen;
+		memcpy(msg_body.set_sta_key_params.key[0].key, key, keylen);
+	}
+
 	msg_body.set_sta_key_params.single_tid_rc = 1;
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
-- 
2.7.4

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

* Re: [PATCH 1/3] wcn36xx: Fix WEP104 encryption type
  2018-05-28 11:29 [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Loic Poulain
  2018-05-28 11:29 ` [PATCH 2/3] wcn36xx: Track associated stations Loic Poulain
  2018-05-28 11:29 ` [PATCH 3/3] wcn36xx: Fix WEP encryption Loic Poulain
@ 2018-06-14 14:24 ` Kalle Valo
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2018-06-14 14:24 UTC (permalink / raw)
  To: Loic Poulain; +Cc: linux-wireless, linux-arm-msm

Loic Poulain <loic.poulain@linaro.org> writes:

> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
>  drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
> index aeb5e6e..4648a78 100644
> --- a/drivers/net/wireless/ath/wcn36xx/main.c
> +++ b/drivers/net/wireless/ath/wcn36xx/main.c
> @@ -512,7 +512,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
>  		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
>  		break;
>  	case WLAN_CIPHER_SUITE_WEP104:
> -		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP40;
> +		vif_priv->encrypt_type = WCN36XX_HAL_ED_WEP104;
>  		break;
>  	case WLAN_CIPHER_SUITE_CCMP:
>  		vif_priv->encrypt_type = WCN36XX_HAL_ED_CCMP;

No empty commit logs, please. I'll add "This is an obvious copy&paste
bug".

-- 
Kalle Valo

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

* Re: [PATCH 3/3] wcn36xx: Fix WEP encryption
  2018-05-28 11:29 ` [PATCH 3/3] wcn36xx: Fix WEP encryption Loic Poulain
@ 2018-06-14 14:28   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2018-06-14 14:28 UTC (permalink / raw)
  To: Loic Poulain; +Cc: linux-wireless, linux-arm-msm

Loic Poulain <loic.poulain@linaro.org> writes:

> In case of WEP encryption, driver has to configure shared key for
> associated station(s). Note that sta pointer is NULL in case of non
> pairwise key, causing NULL pointer dereference with existing code
> (sta_priv->is_data_encrypted). Fix this by using associated sta list
> instead.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

I guess this fix is for AP mode with WEP encryption? And client mode
with WEP doesn't have any issues?

If yes, I'll clarify that in the commit log.

-- 
Kalle Valo

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

end of thread, other threads:[~2018-06-14 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 11:29 [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Loic Poulain
2018-05-28 11:29 ` [PATCH 2/3] wcn36xx: Track associated stations Loic Poulain
2018-05-28 11:29 ` [PATCH 3/3] wcn36xx: Fix WEP encryption Loic Poulain
2018-06-14 14:28   ` Kalle Valo
2018-06-14 14:24 ` [PATCH 1/3] wcn36xx: Fix WEP104 encryption type Kalle Valo

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