Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D578C77B75 for ; Wed, 3 May 2023 06:27:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B14CF8474C; Wed, 3 May 2023 08:27:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.b="15qtPv19"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EFF380ADE; Wed, 3 May 2023 08:27:45 +0200 (CEST) Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 888D884756 for ; Wed, 3 May 2023 08:27:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=34876d5698=patrice.chotard@foss.st.com Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34311mKv025693; Wed, 3 May 2023 08:27:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=eD1es7gT497nt0AScVKjk9gWyTuVDgCt330EwSJb6Xo=; b=15qtPv19CCowptiCM8eIlFlQnl9puc4toKlq6dDNHAWGByOyBvXyDO8bpqNq5t2lHiIT DilwSHLtWPUQgeQjv+4lYv0DeGfnKloJzCqOBmWW9FBFiMZfgOMG3Y5/FEFQoN+L8oIE YehEUAnQLdC+aPjM1ZnXO0Bbu1R7m77EOwRlU8CYcY5pF/wYZSsVXGloXO/HjAx+KPQr nxsDuqgGQU4HImHOA51RQHhoN7VfpLo7V1c6iuf3U1IyRm5mfsJfwzaZ+oDP0bmo3Ity 9TILVTpyK5UVu/SvCgs2Kqn16qqz2Y4OSpE0CybVXv/nq5NbS5ysSCoznEAYCeD5D99l 8A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3q8rnmn6j8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 08:27:41 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D2E5C10002A; Wed, 3 May 2023 08:27:40 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C8EDE211F3D; Wed, 3 May 2023 08:27:40 +0200 (CEST) Received: from [10.201.21.26] (10.201.21.26) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 3 May 2023 08:27:40 +0200 Message-ID: <5ead2bec-9bd9-7d09-8e02-43cbab4142ef@foss.st.com> Date: Wed, 3 May 2023 08:27:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 2/6] stm32mp: bsec: add check on null size in misc ops Content-Language: en-US To: Patrick Delaunay , CC: U-Boot STM32 References: <20230427133638.1477556-1-patrick.delaunay@foss.st.com> <20230427153632.2.Ie06da6845013adef7bc23ff4c379fda001542fa6@changeid> From: Patrice CHOTARD In-Reply-To: <20230427153632.2.Ie06da6845013adef7bc23ff4c379fda001542fa6@changeid> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.201.21.26] X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-03_03,2023-04-27_01,2023-02-09_01 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 4/27/23 15:36, Patrick Delaunay wrote: > Add a protection in misc bsec ops for request with null size. > > For example OP-TEE error occurs when get_eth_nb() return 0 in > setup_mac_address() for unknown part number because U-Boot read 0 OTPs. > > Signed-off-by: Patrick Delaunay > --- > > arch/arm/mach-stm32mp/bsec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c > index f5f4b20d4776..0dc1e5c3fdc4 100644 > --- a/arch/arm/mach-stm32mp/bsec.c > +++ b/arch/arm/mach-stm32mp/bsec.c > @@ -622,7 +622,7 @@ static int stm32mp_bsec_read(struct udevice *dev, int offset, > shadow = false; > } > > - if ((offs % 4) || (size % 4)) > + if ((offs % 4) || (size % 4) || !size) > return -EINVAL; > > if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) { > @@ -678,7 +678,7 @@ static int stm32mp_bsec_write(struct udevice *dev, int offset, > shadow = false; > } > > - if ((offs % 4) || (size % 4)) > + if ((offs % 4) || (size % 4) || !size) > return -EINVAL; > > if (IS_ENABLED(CONFIG_OPTEE) && priv->tee) { Reviewed-by: Patrice Chotard Thanks Patrice