Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp601575lqp; Thu, 21 Mar 2024 09:57:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXi5YTXRFplLJtCmCaFkXtXlOx/yBGJMpDb5U89wZ1nwJQorobGiSAYSIJAWxIxwe3ktt53wzEBP4Ib9JB57iEulbP/kNzc9AOexBVhA== X-Google-Smtp-Source: AGHT+IHyaV/vxL+SY9vbjBB4Xp6vGyTZJUP89QYvOl+LWRBnPWDJ/sDQU2Hws0PlFhUDoM95tfgt X-Received: by 2002:a05:620a:248b:b0:787:a305:3eb4 with SMTP id i11-20020a05620a248b00b00787a3053eb4mr6563504qkn.76.1711040249183; Thu, 21 Mar 2024 09:57:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711040249; cv=pass; d=google.com; s=arc-20160816; b=vOAAUXuIZffYFp07j/9DjVGXN4ZCqjMlPTJhqrYu6rw6FxExn/74zD/LFLVLeQU4HD 27Wc5m7NWP+Y3QiqjPX/A6c9RVtQMTMI3hS4Dz3SHB3t6gsmM0/Ei7W87GpOgTgw2aI3 nbrerfHsXjipHTgL8RNcJtipwdTsdEQXbMcp5+eNmtPIF1BcJCgL8K4xbLwVAe1/XTs7 S92ktN8D+zDWAwoUhA3eDohU2D/220uI8amTWLJFnqCiCicx1bwzqgSHHXhuk/kfNfbZ dAiSA+p2L0vDYJjnxkhVed2rD5kehee0VWB3TqX0aDwpQNnli0zp0BQwrAsfyRtI/nBf NTfw== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=rS+8oI4jnnlG0/QZtTc1eLuWcBGGVJJauaKM2Qw7ri8=; fh=brpjwxOwI0fXFKs1/nTftrzAkABRsmQeA8j4LIXACBY=; b=ujGv1z6O7OmAmdTFB15MilaJrbQk2cFhJczU/UCoGqkvB6Ny5nOcH1Kd/4xqtBDB+q K5NIOtx1ixrYQmW336DnHdhcNQcTGzkLG6DQGLXTF9cnOUAoECA9cVeAJw7YPn/zzoem ZYMPOPyNmCa2hXRwNsUQ99d4Tvc/7eRJrToRZfG4ttyrKFYECi/aZMOfpQmMBUiBgH5I 8toS86iGAipMpTMUG8CMqRFfW0LMZOJPgfBKoaJR00At4H/d8k+28NPxY/tM+I+58LO9 BVBts+AipYLd0oS5t9Pth9REywiuBMEyqYHigW+5f2huzOf4nPx7uFC7tHZVpDcrQr4c G1Ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=BDfOSsfV; 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-110409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110409-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x23-20020a05620a14b700b0078a22357ad8si121533qkj.115.2024.03.21.09.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=BDfOSsfV; 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-110409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110409-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 43F731C233F3 for ; Thu, 21 Mar 2024 16:56:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7290B136648; Thu, 21 Mar 2024 16:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="BDfOSsfV" 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 BE552135416 for ; Thu, 21 Mar 2024 16:47:43 +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=1711039667; cv=none; b=bSESpuSCCwT8Ne9TYyC2cxyJCYE09w7rRysTpxeqOZExGEwmVxA3YKIMrVEhd7MRixdnbjbyvWgqKgMxHr7/xwV4Sb0bZALmYspOOULuMSsHu8eSEfjBWiUWUDo2GqK8CmyZ9q0VI1QdihiJyIpdteLQVAYXHeqCbADga1Wl79Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039667; c=relaxed/simple; bh=ObSkPqFRupEoH5y/NCq6OrbSWOqqf4R3pFWwnS4ji9A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=htbpHary3wd00AskKzaG77eeToBx/uZXumQJzYXmSN7VDp7QrxeyLOuYWGJ6mcoTc5/6AS2huJ5zkxm9GDMnLIjrVvZDcigP9Q3OZ233gKmuPpYEQJQuKBNN/8j9JXolPjt4zQk963mX2Gu7xlnEHpVS0F4VTek4lqE8At50B2o= 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=BDfOSsfV; 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 [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id F250040762DC; Thu, 21 Mar 2024 16:47:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru F250040762DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1711039655; bh=rS+8oI4jnnlG0/QZtTc1eLuWcBGGVJJauaKM2Qw7ri8=; h=From:To:Cc:Subject:Date:From; b=BDfOSsfVeGPh5T+R82Aje3euP6f6ftZ+CKtxP5L1EhePArHYJkbCD9gA2hcrC/x74 nvlTSpqLefevcP/JPjm1V6SXYEel4zVaC9vA16bWILz4ml+/B6l/JMTJumfCgSb4fh R7c4xUg2F+danH1/bxbOgILAFnr4LcrIHnvh+7cM= From: Mikhail Kobuk To: Miquel Raynal Cc: Mikhail Kobuk , Vinod Koul , Kishon Vijay Abraham I , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Alexey Khoroshilov Subject: [PATCH 1/2] phy: marvell: a3700-comphy: Fix out of bounds read Date: Thu, 21 Mar 2024 19:47:30 +0300 Message-ID: <20240321164734.49273-1-m.kobuk@ispras.ru> X-Mailer: git-send-email 2.44.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 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 --- 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 15bf10710de0..1d1db1737422 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