Skip to contentSkip to conversation

nl80211: check channel switch validity better

PATCH In review Johannes Berg 2 participants 4 messages Jan 22, 2014 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 nl80211: check channel switch validity better

From: Johannes Berg <[email protected]>

Before allowing userspace to initiate a channel switch, check that it's actually connected in some sense. Also use a more appropriate error code for the not connected case.

---
 net/wireless/nl80211.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/wireless/nl80211.c +6 -1
index 6e78c62..0c2ef08 100644
@@ -5799,10 +5799,15 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
 
 		/* useless if AP is not running */
 		if (!wdev->beacon_interval)
-			return -EINVAL;
+			return -ENOTCONN;
 		break;
 	case NL80211_IFTYPE_ADHOC:
+		if (!wdev->ssid_len)
+			return -ENOTCONN;
+		break;
 	case NL80211_IFTYPE_MESH_POINT:
+		if (!wdev->mesh_id_len)
+			return -ENOTCONN;
 		break;
 	default:
 		return -EOPNOTSUPP;
Signature · 1 line
1.8.5.1
#1 lore raw
Quoted 19 lines · Johannes Berg

From: Johannes Berg <[email protected]>

Before allowing userspace to initiate a channel switch, check that it's actually connected in some sense. Also use a more appropriate error code for the not connected case.

---
 net/wireless/nl80211.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/wireless/nl80211.c +0 -0
index 6e78c62..0c2ef08 100644
@@ -5799,10 +5799,15 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
 
                /* useless if AP is not running */
                if (!wdev->beacon_interval)

net/wireless/nl80211.c static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) · line 5810

Quoted 10 lines
net/wireless/nl80211.c +6 -1
-                       return -EINVAL;
+                       return -ENOTCONN;
                break;
        case NL80211_IFTYPE_ADHOC:
+               if (!wdev->ssid_len)
+                       return -ENOTCONN;
+               break;
        case NL80211_IFTYPE_MESH_POINT:
+               if (!wdev->mesh_id_len)
+                       return -ENOTCONN;

Hmmm. I'm pretty sure there are some users which set the channel prior to mesh join. This would break that and only allow sending the channel with mesh join?

Thomas

author maintainer
#2 lore raw
Quoted 11 lines · Thomas Pedersen

net/wireless/nl80211.c static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) · line 5802

Quoted 7 lines
net/wireless/nl80211.c +2 -0
@@ -5799,10 +5799,15 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
 
        case NL80211_IFTYPE_MESH_POINT:
+               if (!wdev->mesh_id_len)
+                       return -ENOTCONN;

Hmmm. I'm pretty sure there are some users which set the channel prior to mesh join. This would break that and only allow sending the channel with mesh join?

I don't think channel_switch() is invoked for that? That's done only for run-time switching of the channel with CSA etc.

johannes

#3 lore raw
Quoted 10 lines · Johannes Berg
Quoted 8 lines · Thomas Pedersen
Quoted 7 lines
net/wireless/nl80211.c +2 -0
@@ -5799,10 +5799,15 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
 
        case NL80211_IFTYPE_MESH_POINT:
+               if (!wdev->mesh_id_len)
+                       return -ENOTCONN;
Quoted 6 lines
Quoted 3 lines

Hmmm. I'm pretty sure there are some users which set the channel prior to mesh join. This would break that and only allow sending the channel with mesh join?

I don't think channel_switch() is invoked for that? That's done only for run-time switching of the channel with CSA etc.

Oh right, that was a special case then.

Thanks,
Thomas