Message ID | 20230308094912.1.I852b2b0fb85539e986a45dcfaf765f92e0924536@changeid |
---|---|
State | Accepted |
Commit | 9905cae65e03335aefcb1ebfab5b7ee62d89f64e |
Delegated to: | Tom Rini |
Headers | show |
Series | fs: ext4: check the minimal partition size to mount | expand |
On Wed, Mar 08, 2023 at 09:49:54AM +0100, Patrick Delaunay wrote: > 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 <patrick.delaunay@foss.st.com> Applied to u-boot/master, thanks!
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;
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 <patrick.delaunay@foss.st.com> --- 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(+)