summaryrefslogtreecommitdiff
path: root/sys/net80211
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2020-11-19 20:03:34 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2020-11-19 20:03:34 +0000
commitb61f39293714507d682e028d3ac31ccb3fa2c8a9 (patch)
treea29768d9bd94d9ac15068227f43bd023d7c7ed2b /sys/net80211
parentd96eaa85480684809efe79b3762157c7b20d6f8d (diff)
Always check for EBUSY when the return value of ic_set_key() is tested.
Fixes urtwn(4) repeated DEAUTH and subsequent loss/restoration of link. It was a great dhclient(4) stress test. Note that urtwn(4) is the first and so far only device whose *_set_key() function returns EBUSY. Debugging hints and ok stsp@
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_ioctl.c10
-rw-r--r--sys/net80211/ieee80211_pae_input.c26
-rw-r--r--sys/net80211/ieee80211_proto.c19
3 files changed, 44 insertions, 11 deletions
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index a458e3af59a..e3da39394d2 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.c,v 1.79 2020/01/15 09:34:27 phessler Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.80 2020/11/19 20:03:33 krw Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
@@ -246,8 +246,14 @@ ieee80211_ioctl_setnwkeys(struct ieee80211com *ic,
error = copyin(nwkey->i_key[i].i_keydat, k->k_key, k->k_len);
if (error != 0)
return error;
- if ((error = (*ic->ic_set_key)(ic, NULL, k)) != 0)
+ error = (*ic->ic_set_key)(ic, NULL, k);
+ switch (error) {
+ case 0:
+ case EBUSY:
+ break;
+ default:
return error;
+ }
}
ic->ic_def_txkey = nwkey->i_defkid - 1;
diff --git a/sys/net80211/ieee80211_pae_input.c b/sys/net80211/ieee80211_pae_input.c
index 06d8767ab69..daf550f591f 100644
--- a/sys/net80211/ieee80211_pae_input.c
+++ b/sys/net80211/ieee80211_pae_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_pae_input.c,v 1.36 2020/11/12 13:31:19 krw Exp $ */
+/* $OpenBSD: ieee80211_pae_input.c,v 1.37 2020/11/19 20:03:33 krw Exp $ */
/*-
* Copyright (c) 2007,2008 Damien Bergamini <damien.bergamini@free.fr>
@@ -724,7 +724,11 @@ ieee80211_recv_4way_msg4(struct ieee80211com *ic,
k->k_len = ieee80211_cipher_keylen(k->k_cipher);
memcpy(k->k_key, ni->ni_ptk.tk, k->k_len);
/* install the PTK */
- if ((*ic->ic_set_key)(ic, ni, k) != 0) {
+ switch ((*ic->ic_set_key)(ic, ni, k)) {
+ case 0:
+ case EBUSY:
+ break;
+ default:
IEEE80211_SEND_MGMT(ic, ni,
IEEE80211_FC0_SUBTYPE_DEAUTH,
IEEE80211_REASON_ASSOC_TOOMANY);
@@ -894,7 +898,11 @@ ieee80211_recv_rsn_group_msg1(struct ieee80211com *ic,
k->k_len = keylen;
memcpy(k->k_key, &gtk[8], k->k_len);
/* install the GTK */
- if ((*ic->ic_set_key)(ic, ni, k) != 0) {
+ switch ((*ic->ic_set_key)(ic, ni, k)) {
+ case 0:
+ case EBUSY:
+ break;
+ default:
reason = IEEE80211_REASON_AUTH_LEAVE;
goto deauth;
}
@@ -922,7 +930,11 @@ ieee80211_recv_rsn_group_msg1(struct ieee80211com *ic,
k->k_len = 16;
memcpy(k->k_key, &igtk[14], k->k_len);
/* install the IGTK */
- if ((*ic->ic_set_key)(ic, ni, k) != 0) {
+ switch ((*ic->ic_set_key)(ic, ni, k)) {
+ case 0:
+ case EBUSY:
+ break;
+ default:
reason = IEEE80211_REASON_AUTH_LEAVE;
goto deauth;
}
@@ -1026,7 +1038,11 @@ ieee80211_recv_wpa_group_msg1(struct ieee80211com *ic,
k->k_len = keylen;
memcpy(k->k_key, gtk, k->k_len);
/* install the GTK */
- if ((*ic->ic_set_key)(ic, ni, k) != 0) {
+ switch ((*ic->ic_set_key)(ic, ni, k)) {
+ case 0:
+ case EBUSY:
+ break;
+ default:
IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_DEAUTH,
IEEE80211_REASON_AUTH_LEAVE);
ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index 2027b67c2ff..5170329026a 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.c,v 1.98 2020/05/29 07:37:51 stsp Exp $ */
+/* $OpenBSD: ieee80211_proto.c,v 1.99 2020/11/19 20:03:33 krw Exp $ */
/* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */
/*-
@@ -479,15 +479,26 @@ ieee80211_setkeysdone(struct ieee80211com *ic)
/* install GTK */
kid = (ic->ic_def_txkey == 1) ? 2 : 1;
- if ((*ic->ic_set_key)(ic, ic->ic_bss, &ic->ic_nw_keys[kid]) == 0)
+ switch ((*ic->ic_set_key)(ic, ic->ic_bss, &ic->ic_nw_keys[kid])) {
+ case 0:
+ case EBUSY:
ic->ic_def_txkey = kid;
+ break;
+ default:
+ break;
+ }
if (ic->ic_caps & IEEE80211_C_MFP) {
/* install IGTK */
kid = (ic->ic_igtk_kid == 4) ? 5 : 4;
- if ((*ic->ic_set_key)(ic, ic->ic_bss,
- &ic->ic_nw_keys[kid]) == 0)
+ switch ((*ic->ic_set_key)(ic, ic->ic_bss, &ic->ic_nw_keys[kid])) {
+ case 0:
+ case EBUSY:
ic->ic_igtk_kid = kid;
+ break;
+ default:
+ break;
+ }
}
}