Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2379295lqp; Sun, 24 Mar 2024 16:47:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHprzNDoeu9/fCG6Le9zcC3F+0Bcq8mNTVDWEvsbGVytkevEr4k8QHkugKNuw7AGgZm6FP8E0I8U1yNWI9cE7xpQwAMSm1Mf0jlSfKwg== X-Google-Smtp-Source: AGHT+IEJ9TKpVszCsgKLfJ2LuGoOJ0RoejjKo7ZAo7vq+yfAj4HNXreookhrUK6lb1aKScU3Sjuv X-Received: by 2002:a05:6870:548e:b0:229:fa5a:2fec with SMTP id f14-20020a056870548e00b00229fa5a2fecmr7416485oan.54.1711324058498; Sun, 24 Mar 2024 16:47:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324058; cv=pass; d=google.com; s=arc-20160816; b=EZhqFuKaGYJIxJcovvAAw+I3CMFWwv4nF5RusCuAr7suE8hgdG3NMr3urnI9KX43HL aR4RFosdlzQcpx+pnYkWUrNjO0+9Eh14XJ/Mi6Y/a4Iaf+W4r4vgDDMiHgV4oPQQIQiv 4fBZys8Rz9e0SuSiWi4YLWcCWwgwBqXUrUnpMWdgwIIQ10kU+3P2vFjYOLZLLROoGczJ IQLoloL8iCHvtv18DQGmp1/Fx4VMY7ORS7Ifgy88T2m10d8YZzmUELLLUEbAAoGct5OW efRG7LJnVcqF6ecnaO3L6tvJbCAanTxNaDv0M606JyCubu6Y8NvCTFwvuUnbZyq6rszn S7Og== 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; bh=rImcPEAtEzzNpa31Gsn5/ckXehmNPeQwpNGLsyj2bE0=; fh=akhehA9bjmhcj8OY9/y0FWK2AA+CgDdDtqKmH+H03AQ=; b=GcfMf0XmUCzPYshRclAmk+WBcjl3Byw3oNMm3sK6uBZ3h8q7+fKbofnk6BcwcfIbZ8 wu8YkL91//8Q2/6HuiJMFSV9jjz8KkT4qEyyk7QWkCcODV2uERo7aFZHQmEd/uUsIPfa PMe9gKMiWB9vSLL9y6v79W0VV2QyUTfWkOAuAS0T73mzG8Iy+OI1/nk/XMDjxc3i5WH9 hK+mCJRy6wKyM7NdLp52QgoZ0JpedgPXkg+JBySQWl4r04Ns7CCmOqq/pAAA+hySchJZ ZxsfHARBbK0Ue/BIneZJNHT2oIZJl+yCOm9f8nZf1VqfWPtvQXUOgvVkWzrN9o6Mx1Fs 0m8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HQL0JLHD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113219-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x25-20020a62fb19000000b006e6be6b3ac6si4002819pfm.26.2024.03.24.16.47.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HQL0JLHD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113219-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 12BD628D36F for ; Sun, 24 Mar 2024 23:47:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D046180B7D; Sun, 24 Mar 2024 22:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HQL0JLHD" 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 982F15CDE7; Sun, 24 Mar 2024 22:40:20 +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=1711320020; cv=none; b=HulcfdiclDH/kfDQ/lxj3PDL7SOYIBODR/tR7fuqORk8MDFLvmGaqyo+OXKZGZszA/3tbEDI+WAUmMRS6URUEyISCdZTJc9s0IjVyBRWZR11BSew8ZHXuJYc4p6iz6lYHphCh4JJQbJploic5JEJzBUYO0MwOFQyTpb9JF6UdU4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320020; c=relaxed/simple; bh=HgEcKG5Vx/SjBZU6lXviRdeplvbHJ8xqQ+Kn3L/pG18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fzYr1Fdyqt52ZLy1YzP+9t3NTQJaPO7xiV7MysFsa2EDqVDyffiZoDa4MG3EuXL0pCiRBBGeqVoYOTg0GZ+TZUEjjli9tCkw8wmQ961C4/JrssxLdI8scy/I7T0GxRYchw/FEV85grEfTUFsLLCx+mHOrWS49lzVvaqnLw+zryc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HQL0JLHD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB195C433C7; Sun, 24 Mar 2024 22:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320020; bh=HgEcKG5Vx/SjBZU6lXviRdeplvbHJ8xqQ+Kn3L/pG18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQL0JLHDes9zlR4EmKxRBWiMIe+FQjOwNXYBMByuNNoS62Rk6IOtNgAztlgdVbXZZ j2kUwc9sel3UZdjSKOuKQJEj7v+73TtBjLKG2D+doOOnme1I2dCW86gzDuU+lvwTND TePcZeOfnaWamfUVk9ZWU0828OmTyTo0SAggkSahqtdfooYDS4FkmMDi7gl65jm84A 536i4cnF+ncTcMDuttENiVNKEBVFWGc3fjprEA3K77+ytaVwA91G80wzwtLXBytYzd E71enE16l7YQfWd2AhYOa6XDFme868EwlWsoDJxOLM+aq5ynTyJg2HeEGkoNBUa18R I4L3qAQO0z6TA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?K=C3=A9vin=20L=27h=C3=B4pital?= , Enguerrand de Ribaucourt , Russell King , "David S . Miller" , Sasha Levin Subject: [PATCH 6.8 328/715] net: phy: fix phy_get_internal_delay accessing an empty array Date: Sun, 24 Mar 2024 18:28:27 -0400 Message-ID: <20240324223455.1342824-329-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Kévin L'hôpital [ Upstream commit 4469c0c5b14a0919f5965c7ceac96b523eb57b79 ] The phy_get_internal_delay function could try to access to an empty array in the case that the driver is calling phy_get_internal_delay without defining delay_values and rx-internal-delay-ps or tx-internal-delay-ps is defined to 0 in the device-tree. This will lead to "unable to handle kernel NULL pointer dereference at virtual address 0". To avoid this kernel oops, the test should be delay >= 0. As there is already delay < 0 test just before, the test could only be size == 0. Fixes: 92252eec913b ("net: phy: Add a helper to return the index for of the internal delay") Co-developed-by: Enguerrand de Ribaucourt Signed-off-by: Enguerrand de Ribaucourt Signed-off-by: Kévin L'hôpital Reviewed-by: Russell King (Oracle) Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3611ea64875ef..3ad9bbf65cbeb 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2959,7 +2959,7 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, if (delay < 0) return delay; - if (delay && size == 0) + if (size == 0) return delay; if (delay < delay_values[0] || delay > delay_values[size - 1]) { -- 2.43.0