From mboxrd@z Thu Jan 1 00:00:00 1970 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 322082676E9; Tue, 26 Aug 2025 14:38: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=1756219097; cv=none; b=BrgDusELlXdo+wZfwGoCrttNG+/KMVuLqsR6oYSJU4LR+RopYG2WxTQmm+Tdf4lxmew1fWoY9Kqw3bxvESs8kAC7uByuRySZ9Por3ZbKWcp5swTfBwwcZaqMmYP74iJembls8wItAR40h7+aFJoxgisRnGJz1TkAn5WnhIYoWJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219097; c=relaxed/simple; bh=gMkgl1pz0MaWPGp5iT1Z1e/4tr7iCls0Bbt05+MrUdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W1p6Y9urQt6pFXzRhH312opEKpTfPeH4fewzTSMzMfrsMoYb8muOKNMqHsMiBLXm250hplUDrdl/LGcxte4dVlbikCB2TZCnPiOmk/A7z/nW5hQwBjrx2GP0euhaqPkgTuS43E2ZmAYHiBfZwSd14c3tAn8lC7VFGTmtXuO8z4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M00aZfaW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="M00aZfaW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6AC3C4CEF1; Tue, 26 Aug 2025 14:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756219097; bh=gMkgl1pz0MaWPGp5iT1Z1e/4tr7iCls0Bbt05+MrUdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M00aZfaW7SXAIcq6nlo/BVdAq47SJIVKAa4TJhtX32GesZamEOhLessKF4dcuCvKU EPBmseHBzdma5qzPO0aM39pglZzRdJwnhztLX4wU7Y7kymNKWx71x5pDggu2znbXCi ZneLF0yGOlL3Gps6SctnWhVs29UdhvA4MJMFDj8Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rand Deeb , Miri Korenblit , Sasha Levin Subject: [PATCH 5.4 220/403] wifi: iwlwifi: dvm: fix potential overflow in rs_fill_link_cmd() Date: Tue, 26 Aug 2025 13:09:06 +0200 Message-ID: <20250826110912.910165178@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110905.607690791@linuxfoundation.org> References: <20250826110905.607690791@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rand Deeb [ Upstream commit e3ad987e9dc7d1e12e3f2f1e623f0e174cd0ca78 ] The 'index' variable in the rs_fill_link_cmd() function can reach LINK_QUAL_MAX_RETRY_NUM during the execution of the inner loop. This variable is used as an index for the lq_cmd->rs_table array, which has a size of LINK_QUAL_MAX_RETRY_NUM, without proper validation. Modify the condition of the inner loop to ensure that the 'index' variable does not exceed LINK_QUAL_MAX_RETRY_NUM - 1, thereby preventing any potential overflow issues. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Rand Deeb Link: https://patch.msgid.link/20240313101755.269209-1-rand.sec96@gmail.com Signed-off-by: Miri Korenblit Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c index e68a13c33c45..19defdb43126 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c @@ -2935,7 +2935,7 @@ static void rs_fill_link_cmd(struct iwl_priv *priv, /* Repeat initial/next rate. * For legacy IWL_NUMBER_TRY == 1, this loop will not execute. * For HT IWL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { + while (repeat_rate > 0 && index < (LINK_QUAL_MAX_RETRY_NUM - 1)) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; -- 2.39.5