diff mbox

cfg80211: Disallow HT/WEP in IBSS mode

Message ID 20607.35416.907913.623637@gargle.gargle.HOWL (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Sujith Manoharan Oct. 18, 2012, 4:49 a.m. UTC
Currently, a user is allowed to choose a HT operating channel
with WEP when creating an IBSS network. WEP is not allowed
in HT configuration - this patch ensures that such requests
are denied.

Signed-off-by: Sujith Manoharan <c_manoha@qti.qualcomm.com>
---
 net/wireless/nl80211.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

Comments

Johannes Berg Oct. 18, 2012, 7:27 a.m. UTC | #1
On Thu, 2012-10-18 at 10:19 +0530, Sujith Manoharan wrote:
> Currently, a user is allowed to choose a HT operating channel
> with WEP when creating an IBSS network. WEP is not allowed
> in HT configuration - this patch ensures that such requests
> are denied.

Applied, but

> @@ -733,6 +733,12 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
>  		result->params[parse.idx].key_len = parse.p.key_len;
>  		result->params[parse.idx].key = result->data[parse.idx];
>  		memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len);
> +
> +		if (result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
> +		    result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP104) {

I changed this to be "parse.p.cipher == " to make the lines shorter.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sujith Manoharan Oct. 18, 2012, 8:31 a.m. UTC | #2
Johannes Berg wrote:
> On Thu, 2012-10-18 at 10:19 +0530, Sujith Manoharan wrote:
> > Currently, a user is allowed to choose a HT operating channel
> > with WEP when creating an IBSS network. WEP is not allowed
> > in HT configuration - this patch ensures that such requests
> > are denied.
> 
> Applied, but
> 
> > @@ -733,6 +733,12 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
> >  		result->params[parse.idx].key_len = parse.p.key_len;
> >  		result->params[parse.idx].key = result->data[parse.idx];
> >  		memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len);
> > +
> > +		if (result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
> > +		    result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
> 
> I changed this to be "parse.p.cipher == " to make the lines shorter.

Thanks. :)

Sujith
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0418a6d..e1255e9 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -690,7 +690,7 @@  static int nl80211_parse_key(struct genl_info *info, struct key_parse *k)
 
 static struct cfg80211_cached_keys *
 nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
-		       struct nlattr *keys)
+		       struct nlattr *keys, bool *no_ht)
 {
 	struct key_parse parse;
 	struct nlattr *key;
@@ -733,6 +733,12 @@  nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
 		result->params[parse.idx].key_len = parse.p.key_len;
 		result->params[parse.idx].key = result->data[parse.idx];
 		memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len);
+
+		if (result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
+		    result->params[parse.idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
+			if (no_ht)
+				*no_ht = true;
+		}
 	}
 
 	return result;
@@ -5339,10 +5345,18 @@  static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
 		return -EINVAL;
 
 	if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) {
+		bool no_ht = false;
+
 		connkeys = nl80211_parse_connkeys(rdev,
-					info->attrs[NL80211_ATTR_KEYS]);
+					  info->attrs[NL80211_ATTR_KEYS],
+					  &no_ht);
 		if (IS_ERR(connkeys))
 			return PTR_ERR(connkeys);
+
+		if ((ibss.channel_type != NL80211_CHAN_NO_HT) && no_ht) {
+			kfree(connkeys);
+			return -EINVAL;
+		}
 	}
 
 	ibss.control_port =
@@ -5642,7 +5656,7 @@  static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 
 	if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) {
 		connkeys = nl80211_parse_connkeys(rdev,
-					info->attrs[NL80211_ATTR_KEYS]);
+					  info->attrs[NL80211_ATTR_KEYS], NULL);
 		if (IS_ERR(connkeys))
 			return PTR_ERR(connkeys);
 	}