From patchwork Wed Mar 8 08:49:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 1753982 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.a=rsa-sha256 header.s=selector1 header.b=3GwxY8Li; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWmGw057Cz1yWs for ; Wed, 8 Mar 2023 19:50:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D4A685C8A; Wed, 8 Mar 2023 09:50:09 +0100 (CET) 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="3GwxY8Li"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA66985CAD; Wed, 8 Mar 2023 09:50:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 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 66B0C85CAB for ; Wed, 8 Mar 2023 09:50:05 +0100 (CET) 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=143179b23a=patrick.delaunay@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 32870P9R019779; Wed, 8 Mar 2023 09:49:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=JViWDgpgLIZboDTc4b1qE+ISFZ2N2VBSXtHnm/2WTIM=; b=3GwxY8Li1xVc6d2IotTeZgoAtwHTA0vaCP4TYyH8b8V5+aA6LTxcVp1+d7PSsHhEeyB9 WZOJCbjb2RjkWYTFJh2lujndA0lk7X/RFLeTYxIzMYOtAU0Gst+kNlobwdGvY0vAi9Bx kIHWLF4FESD7txgOXZm5iu6HrVF6JEQD3SB5mS+81F8CepuW4QOZnCPrcjNupXKF3c7A oPRjHoRAdsoPYx5nmK3i00ExC0qCIeE4kPddjxjuhkaNcRb6Sw56qOjPwk5bDTUO802i 7JXnlYns/Qr2plxTKCkOfQMsjK5rmPqfnYTsiebLAfUvMQYasmYQqQ3Jgx9lLb4oifNX sA== 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 3p6fdrjkxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Mar 2023 09:49:58 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 16A4E10002A; Wed, 8 Mar 2023 09:49:57 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id F3C4B210F82; Wed, 8 Mar 2023 09:49:56 +0100 (CET) Received: from localhost (10.48.0.157) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Wed, 8 Mar 2023 09:49:56 +0100 From: Patrick Delaunay To: CC: Patrick Delaunay , Mikhail Ilin , =?utf-8?q?Pali_Roh=C3=A1r?= , Simon Glass , Stefan Roese , U-Boot STM32 Subject: [PATCH] fs: ext4: check the minimal partition size to mount Date: Wed, 8 Mar 2023 09:49:54 +0100 Message-ID: <20230308094912.1.I852b2b0fb85539e986a45dcfaf765f92e0924536@changeid> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.48.0.157] X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_04,2023-03-08_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 No need to mount a too small partition to handle a EXT4 file system. This patch add a test on partition size before to read the SUPERBLOCK_SIZE buffer and avoid error latter in fs_devread() function. Signed-off-by: Patrick Delaunay --- This patch avoids traces when EFI try to detect FS type on one GPT partition with only one LBA (512 octetcs): fs_devread read outside partition 2 Failed to mount ext2 filesystem.. FyleSytem type is searched by efi_disk_create_part() / efi_fs_exists() Even if these traces are removed by commit f337fb9ea8b8 ("fs: Quieten down the filesystems more"), if think it should be good to avoid to read outside partition at the start of this function by a simple test. fs/ext4/ext4_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index f50de7c089e6..9a9c520e22ca 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -2373,6 +2373,10 @@ int ext4fs_mount(unsigned part_length) struct ext2_data *data; int status; struct ext_filesystem *fs = get_fs(); + + if (part_length < SUPERBLOCK_SIZE) + return 0; + data = zalloc(SUPERBLOCK_SIZE); if (!data) return 0;