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 B75EF12CD90; Tue, 30 Apr 2024 11:15:36 +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=1714475736; cv=none; b=Nq8cYkHP1wjGfIbqGbylzxP4sLiDqrbMDnAIt7LYoWcv6iwnuXBA3rVWTbTKjYOHvvc+6idMy5HX1xRTREZZ1hPP6i1TvK2fo1rifOxOnV8qjCusWnG9DjovlNw2xihvAqoF3zxKGznwzqMLs/uO6bMu06I2oItg2oQFXZxMolI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714475736; c=relaxed/simple; bh=6H0Uc240HuNuEla5UGcqFuXX3N1AwE/KTdr7Dw30emw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZhHWE8H+n/lKrn7pEOtr+buLmtZpDNrU9UmKQTxxSvV5twzbWeiXBTHMTos+thEO5YhV9X+VsAg48LPkbZa2uTRnM6u6VFJqKo4IgOmiBiPsxyQjPHLkXKteWT60zXdc3eMm9rrAiRn68PdvPdOqeQuDRHjABqKJyqRqNu4SmU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Nc+kt/Br; 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="Nc+kt/Br" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D545BC2BBFC; Tue, 30 Apr 2024 11:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714475736; bh=6H0Uc240HuNuEla5UGcqFuXX3N1AwE/KTdr7Dw30emw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nc+kt/BrUt6OC6g90hYC25IBTDcGIvjMwGUIboEf0SRvcQMpHlot9LRoLVDFciISV oa7poLHFqq0xSgShR1C5AzykpiJhM8ET5LW+d3KAUY7jfJHqp+ExDs6LtvLqNcn/5w wjZJeQRA2Jkyf5aY2xMrjaj8E3ee4Ok6Tqgl1qOU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikhail Kobuk , Miquel Raynal , Vinod Koul , Sasha Levin Subject: [PATCH 6.6 162/186] phy: marvell: a3700-comphy: Fix out of bounds read Date: Tue, 30 Apr 2024 12:40:14 +0200 Message-ID: <20240430103102.735849965@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103058.010791820@linuxfoundation.org> References: <20240430103058.010791820@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikhail Kobuk [ Upstream commit e4308bc22b9d46cf33165c9dfaeebcf29cd56f04 ] There is an out of bounds read access of 'gbe_phy_init_fix[fix_idx].addr' every iteration after 'fix_idx' reaches 'ARRAY_SIZE(gbe_phy_init_fix)'. Make sure 'gbe_phy_init[addr]' is used when all elements of 'gbe_phy_init_fix' array are handled. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 934337080c6c ("phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation") Signed-off-by: Mikhail Kobuk Reviewed-by: Miquel Raynal Link: https://lore.kernel.org/r/20240321164734.49273-1-m.kobuk@ispras.ru Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c index 24c3371e2bb29..e2d0bf92a9ada 100644 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c @@ -611,11 +611,12 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane, * comparison to 3.125 Gbps values. These register values are * stored in "gbe_phy_init_fix" array. */ - if (!is_1gbps && gbe_phy_init_fix[fix_idx].addr == addr) { + if (!is_1gbps && + fix_idx < ARRAY_SIZE(gbe_phy_init_fix) && + gbe_phy_init_fix[fix_idx].addr == addr) { /* Use new value */ val = gbe_phy_init_fix[fix_idx].value; - if (fix_idx < ARRAY_SIZE(gbe_phy_init_fix)) - fix_idx++; + fix_idx++; } else { val = gbe_phy_init[addr]; } -- 2.43.0