From patchwork Mon Jun 24 22:50:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1951839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7NTj10t5z1ydW for ; Tue, 25 Jun 2024 08:50:32 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLsW1-0000Ft-4h; Mon, 24 Jun 2024 22:50:25 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLsW0-0000Fd-8s for kernel-team@lists.ubuntu.com; Mon, 24 Jun 2024 22:50:24 +0000 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id ED3A73F17E for ; Mon, 24 Jun 2024 22:50:23 +0000 (UTC) Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-375e4d55457so58802155ab.0 for ; Mon, 24 Jun 2024 15:50:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719269422; x=1719874222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jUMpnVUxTRJDIszBCN8KS2lmwsu95RhUZIB9TPIsAxI=; b=jgFbrwJdW8jzLH1uHnsfwUjEZRCUob94AHptc3ZXy1/kn/SWgF6Gt+UR8OFT44ZNZD 375bl6xb2kPuRlHIEfEvSQsAB0RzNtNOkK99xVNByuJAeZMISzAYHuJHBN20MnlkmE7M MaexprriaoWB4KN1ijWF7ksVz/i1gWa8TxR57ImNNKds5/IsN8pg5JbM3/kuRTBQGBxc 9hixXHahp5y01k0cnCua45fe4k5mOYVMUNveELFL2VOeI9Fmqi8FmdqPXOVwyQE2ITiR h4Vp+T4K9jID4IQTC6TYD7WW+jz2PouiLK4dLnLSB/kAnLIbAVxYvnHGp4oU4VWuMuI+ eKkA== X-Gm-Message-State: AOJu0Yz7J1oIf+4pc4dDxnVavsNhREoOJ9HuENgNNDoHYLbLJe0P+avR uqJ0A3U5j3CfD5fUiZv/vYQtSM0OvhMWF8Aa1N+5izRfVaFAPvjeYtT0mybUhbMSUZWFjU65ovB 2cxuGuTNrxYsGH+/NB9cxAQyo5r58l0GtRwCUj3UQpfF7CcTQ3EVQWMsWRyOTc8oczrN1WlTJW+ 2vVXv2IaYB7w== X-Received: by 2002:a05:6e02:1d87:b0:375:a4e5:1dc9 with SMTP id e9e14a558f8ab-3763f5a3e32mr72096375ab.4.1719269422625; Mon, 24 Jun 2024 15:50:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5y9GFTfHgqAAdHgGY5eiUHPp9tBBSknONjGfuDffmB8b24ARyPFHuqiSrxNJysDyQkph3Pg== X-Received: by 2002:a05:6e02:1d87:b0:375:a4e5:1dc9 with SMTP id e9e14a558f8ab-3763f5a3e32mr72096235ab.4.1719269422271; Mon, 24 Jun 2024 15:50:22 -0700 (PDT) Received: from smtp.gmail.com (167-248-51-36.oa02.lnk04.ne.dynamic.allophone.net. [167.248.51.36]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4b9d10ca5casm2287480173.9.2024.06.24.15.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 15:50:22 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH 1/1] phy: marvell: a3700-comphy: Fix out of bounds read Date: Mon, 24 Jun 2024 17:50:20 -0500 Message-Id: <20240624225020.39755-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624225020.39755-1-bethany.jamison@canonical.com> References: <20240624225020.39755-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" 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 (cherry picked from commit 40406dfbc060503d2e0a9e637e98493c54997b3d linux-6.8.y) CVE-2024-35992 Signed-off-by: Bethany Jamison --- 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]; }