Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2924654lqp; Mon, 25 Mar 2024 13:15:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXI/EChdZsOSdReYdauYfMebB4jzpF6z974rdMTdcXYA9fVBpF8gUMxwgtcJ0vrTVweHi7rGY015T75EhAhi//7YQxF1rqYIuTKlCFxaQ== X-Google-Smtp-Source: AGHT+IGXJSaEYEVmz/fCgqRgb9GSjJGN9hpBmveVcL8FyY4f8MQCVMTIM11vDkWySY7QhUN+6MUH X-Received: by 2002:a05:6102:2a52:b0:476:58f8:2b10 with SMTP id gt18-20020a0561022a5200b0047658f82b10mr6864467vsb.18.1711397711366; Mon, 25 Mar 2024 13:15:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711397711; cv=pass; d=google.com; s=arc-20160816; b=NzBRVYNZkAzRy2RNy6P2KR2QPsNFveF0gpzDD4Q/PyHEK1SqAord49h0qlDNpUWVUY fH9n/g3XB+EWXkZxcbsw2YJtBBiZ+68uuyDcu4zM1KAFQ7SXsFVrRT9Frz1qtPEjDqov I7136KSqnmmBmcOZigzKRtMNnoY3rNLdVVPcBUEQvS+ypTuMP3r++6EXaYXXPsCG+cf6 eV++N5HX4D7PN/sMLIFcqotyb6gUzGL/agYc0TFq/QwevdejjkkGPsgOXDJ9Je8Ml4HT HdkmhRoJenEZ2LkzEhen2gzwDNZ9qbYr18V/TzXr1kTKYVrbaOKXasaKJ8MqmhQafr9z 9r5g== 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:dkim-filter; bh=S/22bUxOu8bhnHQdA0DpFckF5vvWg5SfT+9w20uPqdQ=; fh=EgJ5CAHvPR6mEcRxmP1/zq7uJ8Q9F4pHunCamhhT6XY=; b=wxMW3OPH4D6drXJ1dgblm91PYelxUBqD1nVjk26Ou+SVKKt5qMSW2xWbeSAS/ef9gb ZwyuMTNHwzrJ2HzIiPwKmVwe1LN487P/uJ9UeAHG8y14d8U/LDK3YjEAuaIssOnh+JvU f3Ez7aqyOnycky2lWM7L1BxJ6PKUr5ljxTQsWGObal9omS/p5ZnHI9Vwq7AvUqA0E6u4 GNJcns1JxZ3nfnPxzVXkZi/7zogoPdSUfP9gcYaWUzoHdDu8XKDMBsrgeHlbpVx7sWcB mDXvLMcU/yJ0IRLPKh97uhSzS51tGPVuVtsz9xyLM9CM99PdTVATm6nBSrpu45+FC148 sl3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=RBXNiGzM; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-117902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d18-20020a05620a137200b00789f0204f44si5962946qkl.165.2024.03.25.13.15.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=RBXNiGzM; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-117902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 19E061C628EA for ; Mon, 25 Mar 2024 20:15:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C6B24CB54; Mon, 25 Mar 2024 20:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="RBXNiGzM" Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 665FB45023 for ; Mon, 25 Mar 2024 20:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711397583; cv=none; b=cAZ57aGijx0tM+9A6IgHLyyNdVCAHM78EdAbgEjqiNxKQJ5zmfKang4VypJcpUMkj9VNg8hFXtTGx0Ql3s4GQ0qd9+HhNa2jOiDvLRoRizAdsxLBOwtxRWdYT7NTJxVvZdkjOZBwY1SIbgcFt8RlQr9t9NCvUH9zwt7aCkjtvmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711397583; c=relaxed/simple; bh=krJixvHaEzKugH9Yh14vF7eWhxkAI5nrrUEL3NK/SBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YACcIDpNLzz1bAaVMd7HPZdMAMAOwkIRZ1IL1DCP6Ahe9Eht0FuWZEcNX1pIBjH5Wd6fkvjLpT4mvXe2ClQug0sBYQe5rJx8y1sEuza1s3fW3ZsQGb5N29dgREfyzHIrtFfwMYlP19X8jWm62BQWsZwx4BzpKEDUX1NGf3xDd4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=RBXNiGzM; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Received: from tundra.lovozera (unknown [31.173.84.243]) by mail.ispras.ru (Postfix) with ESMTPSA id BF5D640AE01D; Mon, 25 Mar 2024 20:12:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru BF5D640AE01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1711397573; bh=S/22bUxOu8bhnHQdA0DpFckF5vvWg5SfT+9w20uPqdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBXNiGzM+Fhyg5XguFUyjrUeumCcdp9Z6yFbk+NZ0d4lOm1tXhF8kRnBO8G7ihRXR 9zYZEcOYfbNS0KF1MZjSh8kcSXuVJv6teAfLT/DCI0hi8ZL9QpSOwwVpM7hiC+oLME N9qElgdlyyYViWa6TkKPwtXB2/2TfylzQh2QeMgo= From: Mikhail Kobuk To: Miquel Raynal Cc: Mikhail Kobuk , Vinod Koul , Kishon Vijay Abraham I , =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Alexey Khoroshilov Subject: [PATCH v2 1/2] phy: marvell: a3700-comphy: Fix out of bounds read Date: Mon, 25 Mar 2024 23:12:49 +0300 Message-ID: <20240325201254.54445-2-m.kobuk@ispras.ru> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325201254.54445-1-m.kobuk@ispras.ru> References: <20240325201254.54445-1-m.kobuk@ispras.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 41162d7228c9..68710ad1ad70 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.44.0