Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1391C2E3FE for ; Sun, 28 Jun 2026 00:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782606347; cv=none; b=nrzCHQY735yUpTqH/mNoSL4uq5afAvvYjggsBUY3if8empAU4RdcewGxUansXAEbPmvpivSYiewJfqCU7cyk0Q5FfTNuLMGXVvQENDc++mmKdlZpzbV/CExLykDN6PmaXeoVUzV+sa0DLYH4OdjR0y6+qs2bJ38Oj3J09WllAv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782606347; c=relaxed/simple; bh=Gp9heeZl8YOVXLS81sRHuvkbEUIKeicfYWTiUjTKSBE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dzpmzr8939OPA/FrB8B1HfGI6CIgHztX/zzr+YJVr4dT/QygvDqnHLuZ3lKLVQyPmiqLyWamOZ0mP14epbFd8SjQmL3FqNs0kHqPC0QEGsHhltifnTLKLiXnQdZBzMrksdllSgZBmSaTR5WG2DbgRkgTe56g+iux5RAQAHcmh54= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Yy5/MvoO; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yy5/MvoO" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49319ebb3a9so4598135e9.3 for ; Sat, 27 Jun 2026 17:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782606343; x=1783211143; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w+ggCHBmTIi4iroEDf3wYeBaqmZKkqX7ae5VYLvC2Dk=; b=Yy5/MvoOFUCHwQQi3KX9W+0IZlV5baCQ2HyMk8lARPWRP2fkJZsbAMDKPLnEJAb1s+ O/JBp10mly4ZQR801vCxhpgstqA+uOys8Tz4rQQuFkuEojiNGsIYBnhnKF/JoYvP0BfM x9t1JlN/DeX8oXXdg2H4C6qyuJbXrfqfkWfJEEfIx2c+V6VgjWB7mmvoSziKXefekkue IcOFSJwJF2T1MpC7Ol8UFb3VSIwFI3ihxnE1ggSs5YB/YDDJ8n4c16ZUS+/5sv5LmBsz vAh8iu5MMKQVHEUDuRcjeiTmQ9yckZBbhDHYMSomD2Wq6/l/gZE0HBQjXSiwcNTtWe6m rNhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782606343; x=1783211143; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=w+ggCHBmTIi4iroEDf3wYeBaqmZKkqX7ae5VYLvC2Dk=; b=jaorEUxAXk2bzbgPidETjZipeDGXU0CdVbsoVsnbnwMhqctDOj9GbAdcL8ApI9ECKY W+rQ8jpaj3gKDLKAw7BeBaUPlb6GES+YhP6LjtOyv4SLBFkXRBzjHGuipwRYj4jofKqQ p2zPSHrLXBFAfuIx4rA7kVcnILRk6qlRE9OHSk81gbESPSkM/wcF0etKfg1ZtmiP76x6 Q0UFVakHAQbWKwoowewC/Hi+IuqIFYBgzFwNv/8oZeF6GiwWZn/wd/rsykYYGUEGkxPE mvkUcBzX9ira5isJv53Xbqc+BBFzT8uGxC7sAJi87DpU5iPeoc8FB9PUXZhmYB9a10zQ UGJw== X-Forwarded-Encrypted: i=1; AFNElJ+3F6Fgfq/Z02HVSlo8Nmy9a8Wvcerj52ZLMNhKBM+5YsSRakZnl/0Z6lLAas8nsMNTClXvwdDzz+FPbvg=@vger.kernel.org X-Gm-Message-State: AOJu0YwV2IFwfNK340Sns9UOxJE5sE82Y8IGlyVpajMyyV+JOCdb1VN0 8yqiK5NnFbd5WqQTN2dCEP2Ec84Tvo2DnDw+X5jfc2J9Oey8YUd1vs9i X-Gm-Gg: AfdE7cmfwrDqLKMEi3oiMuT/ooZymKiDq47e0FrwGzew9f8Akm2dl0z1TnuwuZydRrw kCyXaOfNkgw6dmqPfHbPGnkIyJedn3gouqQLFNC4d5xN97MQlaIFelsyne+rsKjndhwCkeQhOdo Hb/np0e2/xnYspLmSGSlr8QxkDxmnPB3LpdBQDVFUalFNE2eMi3Zj0egK2pyER2P+Ui2xL7oeDY /pvy5JY+uko6jhyAPc+8LgdIR5lnYNTkxH02M1/Hr89ktfs/DOuz53HPRgomSoQ++sXeEWDymt4 zGknNeRu1hQd2olJIPMnW8w1zqgmhr6DlRovPMbw3/0ktJEGtLeY7PZzQEgG2XsHWRtTTY7QNbn xKV1WxOJX9cpqw93OBTNp/2HjbKqWvtVwDOWX7v8K+GNEQ2FzzgEGnt+MuxB3IVbtZBaOGhuspC zC5IW/MBDEE/X1qNKt/8ntYQHyrA== X-Received: by 2002:a05:600c:6792:b0:492:7187:aa67 with SMTP id 5b1f17b1804b1-4927187aa7dmr68432665e9.30.1782606343532; Sat, 27 Jun 2026 17:25:43 -0700 (PDT) Received: from Dev-Null-MSI ([2a0d:3344:52ac:a808:98a4:4381:be45:536f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926f94f213sm145611055e9.12.2026.06.27.17.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jun 2026 17:25:43 -0700 (PDT) From: Yousef Alhouseen To: Johannes Berg Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Berg , stable@vger.kernel.org, syzbot+21629c14aa749636db9d@syzkaller.appspotmail.com, Yousef Alhouseen Subject: [PATCH] wifi: mac80211_hwsim: avoid treating MCS as legacy rate index Date: Sun, 28 Jun 2026 02:25:37 +0200 Message-ID: <20260628002537.23550-1-alhouseenyousef@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injected HT and VHT rates store an MCS value in rates[0].idx rather than an index into the legacy bitrate table. hwsim nevertheless passes these rates to ieee80211_get_tx_rate() while generating monitor frames and timestamps. A crafted injected frame can therefore read beyond the bitrate table. If the resulting bitrate is zero, mac80211_hwsim_write_tsf() also divides by zero, as observed by syzbot. Use ieee80211_get_tx_rate() only for legacy rates. The existing fallback continues to supply a conservative bitrate where hwsim does not yet calculate MCS rates. Fixes: e75129031f1c ("wifi: mac80211_hwsim: move timestamp writing later in the datapath") Reported-by: syzbot+21629c14aa749636db9d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=21629c14aa749636db9d Cc: stable@vger.kernel.org Signed-off-by: Yousef Alhouseen --- .../net/wireless/virtual/mac80211_hwsim_main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c index 0dd8a6c85953..4a66272526f3 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c @@ -1324,6 +1324,17 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, } } +static struct ieee80211_rate * +mac80211_hwsim_get_tx_rate(struct ieee80211_hw *hw, + struct ieee80211_tx_info *info) +{ + if (info->control.rates[0].flags & + (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)) + return NULL; + + return ieee80211_get_tx_rate(hw, info); +} + static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, struct sk_buff *tx_skb, struct ieee80211_channel *chan) @@ -1333,7 +1344,7 @@ static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw, struct hwsim_radiotap_hdr *hdr; u16 flags, bitrate; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_skb); - struct ieee80211_rate *txrate = ieee80211_get_tx_rate(hw, info); + struct ieee80211_rate *txrate = mac80211_hwsim_get_tx_rate(hw, info); if (!txrate) bitrate = 0; @@ -1603,7 +1614,7 @@ static void mac80211_hwsim_write_tsf(struct mac80211_hwsim_data *data, spin_lock_bh(&data->tsf_offset_lock); - txrate = ieee80211_get_tx_rate(data->hw, info); + txrate = mac80211_hwsim_get_tx_rate(data->hw, info); if (txrate) bitrate = txrate->bitrate; -- 2.54.0