Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp24457rdb; Tue, 16 Jan 2024 13:41:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzSg6Lg+M4/6FMJb+oiXhWKgKM0nn+fA2yiXPDYnxTcsqGY3kuPYIf8GKVaQcowKS9xWc8 X-Received: by 2002:a17:906:e099:b0:a2d:da6e:d64 with SMTP id gh25-20020a170906e09900b00a2dda6e0d64mr1932650ejb.125.1705441289262; Tue, 16 Jan 2024 13:41:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705441289; cv=pass; d=google.com; s=arc-20160816; b=SrlCbAS4xd3rZw6k0S9VNVV7kXY0UhZK9DF+mjTdbDDqFsnvk9A1c8RuLOjvx5ik1w Qhn6g2fAkjbGKIWynuNPtxE+S3rpbSGMkOVzF/K9+o36qi9xgH/0yhjphv8WpE1vtO0R JduP+HDTbIgkZ6G/uTzyklAAuIlcV7+rKWwjVuIREiWgFjAlSV3BK+UdOcBPBJJoJjRl lXWrBR1UNs5SW8+Ca+rSQNmILIpQeXBp3z/v/T/BzcF/dlAfxDeYBpm6J6wJobNWgpip D0j5oiL+7EPGpXWDk6EcYd0Wgi/oUxwWbhms0pGpocnEAD0YGTomf7vwWEsuURri0KJG UvEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=u+egtb7Ql4am0DWkyTf8FpxQ29LLA1Hl9S7gUi50wDg=; fh=2WDu5y1NHteFi9l9QZCAOSmY4VkVXgaade1Crr/MXdY=; b=JFP3EB0E+BXAtJGUhb27p5JncBflgLN/e6aI3zQSOtj5tstvFRiphvq5WWY0ymkvm6 gQHEVXDMb5iYELI+4VqrJjaxfb+bw2KxuhoI7Nq+gt8dc8eVNJ4cKO/5YiNtHGhmGuSr /boSIe0xbBK6lBF1j73IUYPnoKG3b9tUxk3rpM8KL4MtuDLt8McPAxDHQAPF8GxJbsfi RbH1+Pe+V377aEkujrB8NoJIOua1n/6ecB46aW56bYUaQkU+Tkw2EQam7VdHfi03LJED 2BSUe09WMQpO08ui2aLlrQNkE5DBaNiOm2yYbu5qooFH/61cL9p2fUEUZwUCPvDAYeXn RP0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L0Z79Yzp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2048-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t13-20020a17090605cd00b00a2c34d90a16si5119070ejt.662.2024.01.16.13.41.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 13:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2048-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L0Z79Yzp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2048-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 05DE81F2749B for ; Tue, 16 Jan 2024 21:41:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99A5D15B973; Tue, 16 Jan 2024 20:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L0Z79Yzp" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701C315B96E; Tue, 16 Jan 2024 20:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435277; cv=none; b=fitBSpaPPRX0Eri0KeEKU+tJmmt4JHWXryYMk/YKiRFQKAelVb4Efvh+iNjr+HbehBREp/36eGT2cPQpfbiNtup0+BRz8TF4jBLnvpMXTwAgiRnkMdErgn7bOzqqevxTcSGV1tbRJBbSv/X8Xv47fIMU75TdBpJfEEIKG6JCZvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435277; c=relaxed/simple; bh=kYflBUvRL0rpmTlBidNtRLsXDE9oX/Cv4YkXmWkF1To=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:Content-Type:X-stable: X-Patchwork-Hint:X-stable-base:Content-Transfer-Encoding; b=DDg9GcdBxduV/wOmGhvY9yrtloHCzNjn14qzGrMPR6LIDq/QfOO9fUWEXc3/qDqhpb0tYSZ6703Izom/NXZCsvqr/hbNN0uDCUn7SDUsgtiUjscotl2+DWwESsG1I8dIP0WaJTzeA3uD/KGD5XGln5nIQJThgqnpwXFgKPBNnRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L0Z79Yzp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15886C433F1; Tue, 16 Jan 2024 20:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705435276; bh=kYflBUvRL0rpmTlBidNtRLsXDE9oX/Cv4YkXmWkF1To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0Z79Yzpar7cA4RQeSKEkJRW6f24ZoXKcZeq9QCOemuVqlbkIDYmuKor5++bm7h9m 1vn7C7UH6+ZHIrk+YTrcalv/Q3K6hmlT9tDGv54d/Nkl8e0Bv4ZlEceYeO59VrA1YA kf18LLoZtib/a3iJ36UQXqCTnhmCa8tglUMI8RJPyh7Aj1c0KgdwB58C1ek46HRE2G IibrjH1qK4vuntclnyMAHDz0Q6Ow+ITz8TzJHLTgPpWdIJXIrMSkjRQVZQfccZl4A4 W9b05Vs1Ed1FHYIt9bHWDRd6jl3z7t6bbD2g/to7xR9S6mZtWGSwMonbAAlHtipo2A 881l0ijLVX4LA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Minsuk Kang , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Kalle Valo , Sasha Levin , kvalo@kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 12/44] wifi: ath9k: Fix potential array-index-out-of-bounds read in ath9k_htc_txstatus() Date: Tue, 16 Jan 2024 14:59:41 -0500 Message-ID: <20240116200044.258335-12-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116200044.258335-1-sashal@kernel.org> References: <20240116200044.258335-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.208 Content-Transfer-Encoding: 8bit From: Minsuk Kang [ Upstream commit 2adc886244dff60f948497b59affb6c6ebb3c348 ] Fix an array-index-out-of-bounds read in ath9k_htc_txstatus(). The bug occurs when txs->cnt, data from a URB provided by a USB device, is bigger than the size of the array txs->txstatus, which is HTC_MAX_TX_STATUS. WARN_ON() already checks it, but there is no bug handling code after the check. Make the function return if that is the case. Found by a modified version of syzkaller. UBSAN: array-index-out-of-bounds in htc_drv_txrx.c index 13 is out of range for type '__wmi_event_txstatus [12]' Call Trace: ath9k_htc_txstatus ath9k_wmi_event_tasklet tasklet_action_common __do_softirq irq_exit_rxu sysvec_apic_timer_interrupt Signed-off-by: Minsuk Kang Acked-by: Toke Høiland-Jørgensen Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20231113065756.1491991-1-linuxlovemin@yonsei.ac.kr Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c index 622fc7f17040..5037142c5a82 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c @@ -647,9 +647,10 @@ void ath9k_htc_txstatus(struct ath9k_htc_priv *priv, void *wmi_event) struct ath9k_htc_tx_event *tx_pend; int i; - for (i = 0; i < txs->cnt; i++) { - WARN_ON(txs->cnt > HTC_MAX_TX_STATUS); + if (WARN_ON_ONCE(txs->cnt > HTC_MAX_TX_STATUS)) + return; + for (i = 0; i < txs->cnt; i++) { __txs = &txs->txstatus[i]; skb = ath9k_htc_tx_get_packet(priv, __txs); -- 2.43.0