From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 16/20] wifi: mt76: mt7996: divide by the full TWT wake interval
Date: Mon, 23 Nov 2026 14:49:15 +0100 [thread overview]
Message-ID: <20261123134920.154270-16-nbd@nbd.name> (raw)
In-Reply-To: <20261123134920.154270-1-nbd@nbd.name>
mt7996_mac_add_twt_setup() passes the 64-bit wake interval of a TWT
request as the 32-bit divisor of div_u64_rem(). An interval that is a
multiple of 2^32 us thus gives a division by zero, which traps on x86
with the driver mutex held.
Any device in range can trigger this with one TWT Setup frame. The frame
is not robust, so it is accepted with the address of any associated
station. Neither mac80211 nor mt7996_mac_check_twt_req() bounds the
exponent or the mantissa.
Divide by the full interval with div64_u64_rem().
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 229f797f4302..d724ac425b42 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -3369,13 +3369,12 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
if (sta_setup_cmd == TWT_SETUP_CMD_REQUEST ||
sta_setup_cmd == TWT_SETUP_CMD_SUGGEST) {
u64 interval = (u64)le16_to_cpu(twt_agrt->mantissa) << exp;
- u64 flow_tsf, curr_tsf;
- u32 rem;
+ u64 flow_tsf, curr_tsf, rem;
flow->sched = true;
flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow);
curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink);
- div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
+ div64_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
flow_tsf = curr_tsf + interval - rem;
twt_agrt->twt = cpu_to_le64(flow_tsf);
} else {
--
2.47.3
next prev parent reply other threads:[~2026-11-23 13:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:49 [PATCH mt76-next 01/20] wifi: mt76: mt7925: undo the BSS of a failed interface add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: keep the embedded link's BMC wcid after a failed add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 03/20] wifi: mt76: mt7915: read the PS sync state of mt7986 and mt7981 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 04/20] wifi: mt76: mt7915: leave the BIP check of a group frame to mac80211 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 05/20] wifi: mt76: mt7921: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 07/20] wifi: mt76: mt7615: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: use wcid_to_sta() in mt7925_mac_write_txwi_8023() Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 09/20] wifi: mt76: log the firmware status of a failed MCU command Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 10/20] wifi: mt76: mt7996: clear the ADM counters only in the airtime poll Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: send mt7981 only the group units its firmware holds Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 12/20] wifi: mt76: take the DFS state from the off-channel flag Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 13/20] wifi: mt76: read roc_phy and roc_link once without the mutex Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: add only the active links of a station MLD's peer Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: resume the radar TX stop at an operating channel set Felix Fietkau
2026-11-23 13:49 ` Felix Fietkau [this message]
2026-11-23 13:49 ` [PATCH mt76-next 17/20] wifi: mt76: mt7915: divide by the full TWT wake interval Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 18/20] wifi: mt76: mt7996: send the SRG bitmaps in one block per band Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 19/20] wifi: mt76: connac: set the band of an RX block ack scoreboard reset Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: reset the CCA statistics of band 1 on mt7916 Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123134920.154270-16-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox