nl80211: Reject disconnect commands except from conn_owner
PATCH 1/1 nl80211: Reject disconnect commands except from conn_owner
Reject NL80211_CMD_DISCONNECT, NL80211_CMD_DISASSOCIATE, NL80211_CMD_DEAUTHENTICATE and NL80211_CMD_ASSOCIATE commands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
--- net/wireless/nl80211.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/wireless/nl80211.c +16 -0
@@ -8303,6 +8303,10 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)const u8 *bssid, *ssid;int err, ssid_len =0 ; +if (dev->ieee80211_ptr->conn_owner_nlportid && + dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) +return -EPERM ; +if (!is_valid_ie_attr (info->attrs[NL80211_ATTR_IE ]))return -EINVAL ;
@@ -8425,6 +8429,10 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)u16 reason_code;bool local_state_change; +if (dev->ieee80211_ptr->conn_owner_nlportid && + dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) +return -EPERM ; +if (!is_valid_ie_attr (info->attrs[NL80211_ATTR_IE ]))return -EINVAL ;
@@ -8472,6 +8480,10 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)u16 reason_code;bool local_state_change; +if (dev->ieee80211_ptr->conn_owner_nlportid && + dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) +return -EPERM ; +if (!is_valid_ie_attr (info->attrs[NL80211_ATTR_IE ]))return -EINVAL ;
@@ -9234,6 +9246,10 @@ static int nl80211_disconnect(struct sk_buff *skb, struct genl_info *info)u16 reason;int ret; +if (dev->ieee80211_ptr->conn_owner_nlportid && + dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) +return -EPERM ; +if (!info->attrs[NL80211_ATTR_REASON_CODE ]) reason =WLAN_REASON_DEAUTH_LEAVING ;else
Signature · 1 line
2.14.1
Quoted 9 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
Signature · 1 line
Kalle Valo
Quoted 6 lines · Kalle Valo
Quoted 5 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.
Quoted 6 lines
Quoted 4 lines
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Best regards
Johannes Berg
maintainerQuoted 7 lines · Andrew Zaborowski
Quoted 6 lines · Kalle Valo
Quoted 5 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Looks fine to me, please resend if you want it in :)
johannes
Quoted 13 lines · Johannes Berg
Quoted 12 lines · Andrew Zaborowski
Quoted 11 lines · Kalle Valo
Quoted 9 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Looks fine to me, please resend if you want it in :)
Do we really want this? Is the referred chaos hypothetical or an actual issue. Nothing stops me from doing an 'ifconfig down' so why should 'iw disconnect' be any different. As far I can tell it does not affect my testing environment, but particularly in such use-cases I can expect issues adopting this change, which is also hypothetical of course ;-)
Regards,
Arend
Johannes Berg
maintainerQuoted 19 lines · Arend van Spriel
Quoted 18 lines · Johannes Berg
Quoted 16 lines · Andrew Zaborowski
Quoted 6 lines · Kalle Valo
Quoted 5 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.Quoted 6 lines
Quoted 4 lines
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Quoted 7 lines
Quoted 1 line
Looks fine to me, please resend if you want it in :)
Do we really want this? Is the referred chaos hypothetical or an actual issue. Nothing stops me from doing an 'ifconfig down' so why should 'iw disconnect' be any different. As far I can tell it does not affect my testing environment, but particularly in such use-cases I can expect issues adopting this change, which is also hypothetical of course ;-)
Yeah, it's a good question. But it might help with inadvertent issues, like starting wpa_s which immediately disconnects if it finds something connected. If that fails, perhaps you have a better chance of noticing the error?
johannes
Quoted 28 lines · Johannes Berg
Quoted 19 lines · Arend van Spriel
Quoted 18 lines · Johannes Berg
Quoted 16 lines · Andrew Zaborowski
Quoted 6 lines · Kalle Valo
Quoted 5 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.Quoted 6 lines
Quoted 4 lines
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Quoted 7 lines
Quoted 1 line
Looks fine to me, please resend if you want it in :)
Do we really want this? Is the referred chaos hypothetical or an actual issue. Nothing stops me from doing an 'ifconfig down' so why should 'iw disconnect' be any different. As far I can tell it does not affect my testing environment, but particularly in such use-cases I can expect issues adopting this change, which is also hypothetical of course ;-)
Quoted 4 lines
Yeah, it's a good question. But it might help with inadvertent issues, like starting
wpa_swhich immediately disconnects if it finds something connected. If that fails, perhaps you have a better chance of noticing the error?
Sure. I guess we all have been there kicking of wpa_s and discovering there is already one running in the background. I am just a bit squeamish to change the behavior like this. Hmmmm. Is wpa_s already using SOCKET_OWNER. If so, I might create a patch to opt-out for that so people can knowingly choose chaos ;-)
Regards,
Arend
Hi,
Quoted 28 lines · Johannes Berg
Quoted 19 lines · Arend van Spriel
Quoted 18 lines · Johannes Berg
Quoted 16 lines · Andrew Zaborowski
Quoted 6 lines · Kalle Valo
Quoted 5 lines · Andrew Zaborowski
Reject
NL80211_CMD_DISCONNECT,NL80211_CMD_DISASSOCIATE,NL80211_CMD_DEAUTHENTICATEandNL80211_CMD_ASSOCIATEcommands from clients other than the connection owner set in the connect, authenticate or associate commands, if it was set.Quoted 6 lines
Quoted 4 lines
The main point of this check is to prevent chaos when two processes try to use nl80211 at the same time, it's not a security measure. The same thing should possibly be done for JOIN_IBSS/LEAVE_IBSS and START_AP/STOP_AP.
s-o-b missing.
True, thanks. Also I was going to send this as an RFC.
Quoted 7 lines
Quoted 1 line
Looks fine to me, please resend if you want it in :)
Do we really want this? Is the referred chaos hypothetical or an actual issue. Nothing stops me from doing an 'ifconfig down' so why should 'iw disconnect' be any different. As far I can tell it does not affect my testing environment, but particularly in such use-cases I can expect issues adopting this change, which is also hypothetical of course ;-)
Quoted 4 lines
Yeah, it's a good question. But it might help with inadvertent issues, like starting
wpa_swhich immediately disconnects if it finds something connected. If that fails, perhaps you have a better chance of noticing the error?
This patch was only motivated by a case of running both iwd and wpa_supplicant simultaneously by mistake. They can both handle things like 'ifconfig down', but when one daemon tries to connect the other immediately commands a disconnect (makes sense) and it made us think whether it was more correct if that disconnect command failed. I'm not really sure what's right here so I wanted to float this idea.
Best regards
Quoted 10 lines · Denis Kenzior
Hi Arend,
Quoted 7 lines
Sure. I guess we all have been there kicking of
wpa_sand discovering there is already one running in the background. I am just a bit squeamish to change the behavior like this. Hmmmm. Iswpa_salready usingSOCKET_OWNER. If so, I might create a patch to opt-out for that so people can knowingly choose chaos ;-)
Quoted 3 lines
wpa_sis usingSOCKET_OWNERthese days. However, with the introduction of Control Port over NL80211, just getting rid ofSOCKET_OWNERmight not be that easy.
I have a regression test script employing py80211 which listens for connect event. Right now I am using an older wpa_s, but the above will screw it up.
If I recall correctly the mlme notification needed to be unicast, because multicast was not 100% reliable, right? Would it be acceptable to send unicast to the socket owner and still do the multicast or are we already doing that? If not, that would fix my imminent issue.
Regards,
Arend
Hi Arend,
Quoted 11 lines · Arend van Spriel
Quoted 10 lines · Denis Kenzior
Hi Arend,
Quoted 7 lines
Sure. I guess we all have been there kicking of
wpa_sand discovering there is already one running in the background. I am just a bit squeamish to change the behavior like this. Hmmmm. Iswpa_salready usingSOCKET_OWNER. If so, I might create a patch to opt-out for that so people can knowingly choose chaos ;-)
Quoted 5 lines
Quoted 3 lines
wpa_sis usingSOCKET_OWNERthese days. However, with the introduction of Control Port over NL80211, just getting rid ofSOCKET_OWNERmight not be that easy.I have a regression test script employing py80211 which listens for connect event. Right now I am using an older
wpa_s, but the above will screw it up.
So it is still early in the morning for me and you might have to talk slower. But let me take a stab anyway :)
What will screw up? The connect event is always multicast, so you should still receive it regardless of SOCKET_OWNER / Control Port over NL80211.
Quoted 3 lines
If I recall correctly the mlme notification needed to be unicast, because multicast was not 100% reliable, right? Would it be acceptable to send unicast to the socket owner and still do the multicast or are we already doing that? If not, that would fix my imminent issue.
Control Port events are only unicast to the application that is the SOCKET_OWNER. E.g. either wpa_s or iwd. They are never multicast as nobody else could make sense of them anyway due to lack of passphrase / nonces.
The other 'regular' events like Disconnect, Connect, etc are still multicast. What this patch does is prevents some app from rudely coming in and sending a Disconnect on an interface which is being managed by another process, e.g. iwd or wpa_s, that has set the SOCKET_OWNER flag.
Regards,
-Denis