From 720f4ea4e7a4da998bab272c6bdc876115dcf380 Mon Sep 17 00:00:00 2001 From: stsp Date: Wed, 29 May 2024 07:27:33 +0000 Subject: [PATCH] fix WEP on athn(4) USB hostap Deferring installation of software crypto keys to a task context is not needed and results in race conditions that trigger the infamous "key not installed for sw crypto" panic. --- sys/dev/usb/if_athn_usb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c index b0e00117202..0eed5ca2a34 100644 --- a/sys/dev/usb/if_athn_usb.c +++ b/sys/dev/usb/if_athn_usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_athn_usb.c,v 1.66 2024/05/23 03:21:08 jsg Exp $ */ +/* $OpenBSD: if_athn_usb.c,v 1.67 2024/05/29 07:27:33 stsp Exp $ */ /*- * Copyright (c) 2011 Damien Bergamini @@ -1640,6 +1640,11 @@ athn_usb_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, (IFF_UP | IFF_RUNNING)) return (0); + if (k->k_cipher != IEEE80211_CIPHER_CCMP) { + /* Use software crypto for ciphers other than CCMP. */ + return ieee80211_set_key(ic, ni, k); + } + /* Do it in a process context. */ cmd.ni = (ni != NULL) ? ieee80211_ref_node(ni) : NULL; cmd.key = k; @@ -1682,6 +1687,11 @@ athn_usb_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, ic->ic_state != IEEE80211_S_RUN) return; /* Nothing to do. */ + if (k->k_cipher != IEEE80211_CIPHER_CCMP) { + ieee80211_delete_key(ic, ni, k); + return; + } + /* Do it in a process context. */ cmd.ni = (ni != NULL) ? ieee80211_ref_node(ni) : NULL; cmd.key = k; -- 2.20.1