Skip to contentSkip to conversation

Revert "fs: ext4: check the minimal partition size to mount"

PATCH In review Sean Anderson 4 participants 4 messages Sep 30, 2023 – Oct 18, 2023 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "fs: ext4: check the minimal partition size to mount"

This check breaks small partitions (under 1024 blocks) because part_length is in units of part.blksz and not bytes. Given the purpose of this function, we really want to make sure the partition is SUPERBLOCK_START + SUPERBLOCK_SIZE (2048) bytes so we can call ext4_read_superblock without error.

The obvious solution is to convert callers from things like

ext4fs_mount(part_info.size)

to

	ext4fs_mount(part_info.size * part_info.blksz);

However, I'm not really a fan of the bloat that would cause, especially since the error is now suppressed. I think the best course of action here is to just revert the patch.

This reverts commit 9905cae65e03335aefcb1ebfab5b7ee62d89f64e.

---

 fs/ext4/ext4_common.c | 4 ----
 1 file changed, 4 deletions(-)
fs/ext4/ext4_common.c +0 -4
index 9a9c520e22c..f50de7c089e 100644
@@ -2373,10 +2373,6 @@ 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;
Signature · 1 line
2.37.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Sean Anderson

This check breaks small partitions (under 1024 blocks) because part_length is in units of part.blksz and not bytes. Given the purpose of this function, we really want to make sure the partition is SUPERBLOCK_START + SUPERBLOCK_SIZE (2048) bytes so we can call ext4_read_superblock without error.

The obvious solution is to convert callers from things like

ext4fs_mount(part_info.size)

to

        ext4fs_mount(part_info.size * part_info.blksz);

However, I'm not really a fan of the bloat that would cause, especially since the error is now suppressed. I think the best course of action here is to just revert the patch.

Quoted 7 lines

This reverts commit 9905cae65e03335aefcb1ebfab5b7ee62d89f64e.

---

 fs/ext4/ext4_common.c | 4 ----
 1 file changed, 4 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Sean Anderson

Hi,

Quoted 31 lines · Sean Anderson

This check breaks small partitions (under 1024 blocks) because part_length is in units of part.blksz and not bytes. Given the purpose of this function, we really want to make sure the partition is SUPERBLOCK_START + SUPERBLOCK_SIZE (2048) bytes so we can call ext4_read_superblock without error.

The obvious solution is to convert callers from things like

ext4fs_mount(part_info.size)

to

	ext4fs_mount(part_info.size * part_info.blksz);

However, I'm not really a fan of the bloat that would cause, especially since the error is now suppressed. I think the best course of action here is to just revert the patch.

This reverts commit 9905cae65e03335aefcb1ebfab5b7ee62d89f64e.

---

  fs/ext4/ext4_common.c | 4 ----
  1 file changed, 4 deletions(-)
fs/ext4/ext4_common.c +0 -0
index 9a9c520e22c..f50de7c089e 100644

fs/ext4/ext4_common.c int ext4fs_mount(unsigned part_length) · line 2378

Quoted 10 lines
fs/ext4/ext4_common.c +0 -4
@@ -2373,10 +2373,6 @@ 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;

Agreed, I introduced error for part size in parameter

(in blk multiple even if after dev read if done after with bytes size)

And with caller change (part_info.size * part_info.blksz) we have risk of overflow for large ex4 partition.

minor remark: "part_length" is no more used....

it can be removed to avoid warining ?

include/ext4fs.h:149:int ext4fs_mount(void);

or use the tag  "__always_unused":

int ext4fs_mount(unsigned __always_unused part_length) {

With the remarks:

Thanks
Patrick

#3 lore raw
In reply to Sean Anderson
Quoted 9 lines · Sean Anderson

This check breaks small partitions (under 1024 blocks) because part_length is in units of part.blksz and not bytes. Given the purpose of this function, we really want to make sure the partition is SUPERBLOCK_START + SUPERBLOCK_SIZE (2048) bytes so we can call ext4_read_superblock without error.

The obvious solution is to convert callers from things like

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom