diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2009-11-03 17:36:59 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2009-11-03 17:36:59 +0000 |
commit | 20ee799719c991979f4893eb24b47594ddeac537 (patch) | |
tree | c34124ea7a83536e3ec6f8ea41fce1e34a73847b /sys | |
parent | 4cebf82c323cb4ae3ffd5641d64f7d8f6672b220 (diff) |
setting of WEP keys is defered until interface is brought up,
so do nothing in set_key() if the interface is not up and running.
fixes a panic reported by Steph (frlinux at gmail dot com) with
run(4) on misc
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/rt2860.c | 19 | ||||
-rw-r--r-- | sys/dev/usb/if_otus.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/if_run.c | 19 |
3 files changed, 30 insertions, 15 deletions
diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c index 5f977cb89df..102aab656c8 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860.c,v 1.36 2009/11/01 12:08:36 damien Exp $ */ +/* $OpenBSD: rt2860.c,v 1.37 2009/11/03 17:36:58 damien Exp $ */ /*- * Copyright (c) 2007, 2008 @@ -2177,6 +2177,11 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, uint32_t attr; uint8_t mode, wcid, iv[8]; + /* defer setting of WEP keys until interface is brought up */ + if ((ic->ic_if.if_flags & (IFF_UP | IFF_RUNNING)) != + (IFF_UP | IFF_RUNNING)) + return 0; + /* map net80211 cipher to RT2860 security mode */ switch (k->k_cipher) { case IEEE80211_CIPHER_WEP40: @@ -2891,12 +2896,6 @@ rt2860_init(struct ifnet *ifp) /* turn radio LED on */ rt2860_set_leds(sc, RT2860_LED_RADIO); - if (ic->ic_flags & IEEE80211_F_WEPON) { - /* install WEP keys */ - for (i = 0; i < IEEE80211_WEP_NKID; i++) - (void)rt2860_set_key(ic, NULL, &ic->ic_nw_keys[i]); - } - /* enable Tx/Rx DMA engine */ if ((error = rt2860_txrx_enable(sc)) != 0) { rt2860_stop(ifp, 1); @@ -2914,6 +2913,12 @@ rt2860_init(struct ifnet *ifp) ifp->if_flags &= ~IFF_OACTIVE; ifp->if_flags |= IFF_RUNNING; + if (ic->ic_flags & IEEE80211_F_WEPON) { + /* install WEP keys */ + for (i = 0; i < IEEE80211_WEP_NKID; i++) + (void)rt2860_set_key(ic, NULL, &ic->ic_nw_keys[i]); + } + if (ic->ic_opmode != IEEE80211_M_MONITOR) ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); else diff --git a/sys/dev/usb/if_otus.c b/sys/dev/usb/if_otus.c index ead0b5277fc..117a3a5d83d 100644 --- a/sys/dev/usb/if_otus.c +++ b/sys/dev/usb/if_otus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_otus.c,v 1.12 2009/09/15 18:44:55 damien Exp $ */ +/* $OpenBSD: if_otus.c,v 1.13 2009/11/03 17:36:58 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -2047,6 +2047,11 @@ otus_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, struct otus_softc *sc = ic->ic_softc; struct otus_cmd_key cmd; + /* Defer setting of WEP keys until interface is brought up. */ + if ((ic->ic_if.if_flags & (IFF_UP | IFF_RUNNING)) != + (IFF_UP | IFF_RUNNING)) + return 0; + /* Do it in a process context. */ cmd.key = *k; cmd.associd = (ni != NULL) ? ni->ni_associd : 0; diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c index af88d5f8558..e898b564ddc 100644 --- a/sys/dev/usb/if_run.c +++ b/sys/dev/usb/if_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_run.c,v 1.32 2009/09/16 15:44:59 damien Exp $ */ +/* $OpenBSD: if_run.c,v 1.33 2009/11/03 17:36:58 damien Exp $ */ /*- * Copyright (c) 2008,2009 Damien Bergamini <damien.bergamini@free.fr> @@ -1515,6 +1515,11 @@ run_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, struct run_softc *sc = ic->ic_softc; struct run_cmd_key cmd; + /* defer setting of WEP keys until interface is brought up */ + if ((ic->ic_if.if_flags & (IFF_UP | IFF_RUNNING)) != + (IFF_UP | IFF_RUNNING)) + return 0; + /* do it in a process context */ cmd.key = *k; cmd.associd = (ni != NULL) ? ni->ni_associd : 0; @@ -3013,12 +3018,6 @@ run_init(struct ifnet *ifp) /* turn radio LED on */ run_set_leds(sc, RT2860_LED_RADIO); - if (ic->ic_flags & IEEE80211_F_WEPON) { - /* install WEP keys */ - for (i = 0; i < IEEE80211_WEP_NKID; i++) - (void)run_set_key(ic, NULL, &ic->ic_nw_keys[i]); - } - for (i = 0; i < RUN_RX_RING_COUNT; i++) { struct run_rx_data *data = &sc->rxq.data[i]; @@ -3036,6 +3035,12 @@ run_init(struct ifnet *ifp) ifp->if_flags &= ~IFF_OACTIVE; ifp->if_flags |= IFF_RUNNING; + if (ic->ic_flags & IEEE80211_F_WEPON) { + /* install WEP keys */ + for (i = 0; i < IEEE80211_WEP_NKID; i++) + (void)run_set_key(ic, NULL, &ic->ic_nw_keys[i]); + } + if (ic->ic_opmode == IEEE80211_M_MONITOR) ieee80211_new_state(ic, IEEE80211_S_RUN, -1); else |