summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2020-05-01 14:04:18 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2020-05-01 14:04:18 +0000
commit29765bb4b91c35bc8b94001c6ff75c5521df4719 (patch)
tree21eacae6fb432f319e8cfe1bb7d1915128fab108
parent0c7e4077a8fdb4367d4e09c68ccfe0cb7cb60b06 (diff)
Prevent divide-by-zero in MiRA which I managed to trigger with iwn(4).
ok deraadt@
-rw-r--r--sys/dev/pci/if_iwn.c3
-rw-r--r--sys/net80211/ieee80211_mira.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index b0fb1ec2174..6b6331d167a 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.227 2020/04/27 08:02:24 stsp Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.228 2020/05/01 14:04:17 stsp Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -2402,6 +2402,7 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc,
*/
if (txdata->m != NULL && txdata->ampdu_id == id &&
txdata->ampdu_txmcs == ni->ni_txmcs &&
+ txdata->ampdu_nframes > 0 &&
(SEQ_LT(ba->ba_winend, s) ||
(ba->ba_bitmap & (1 << bit)) == 0)) {
have_ack++;
diff --git a/sys/net80211/ieee80211_mira.c b/sys/net80211/ieee80211_mira.c
index 23bfcf0a331..bceb55f83a6 100644
--- a/sys/net80211/ieee80211_mira.c
+++ b/sys/net80211/ieee80211_mira.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_mira.c,v 1.29 2020/04/17 07:09:05 stsp Exp $ */
+/* $OpenBSD: ieee80211_mira.c,v 1.30 2020/05/01 14:04:17 stsp Exp $ */
/*
* Copyright (c) 2016 Stefan Sperling <stsp@openbsd.org>
@@ -400,6 +400,9 @@ ieee80211_mira_update_stats(struct ieee80211_mira_node *mn,
uint64_t rate = ieee80211_mira_get_txrate(ni->ni_txmcs, sgi);
struct ieee80211_mira_goodput_stats *g = &mn->g[ni->ni_txmcs];
+ if (mn->frames == 0)
+ return; /* avoid divide-by-zero in sfer calculation below */
+
g->nprobes += mn->agglen;
g->nprobe_bytes += mn->ampdu_size;