* [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs
@ 2016-12-12 0:25 FrostyBytes
2016-12-12 15:48 ` Tom Rini
2016-12-12 23:42 ` stefan.bruens at rwth-aachen.de
0 siblings, 2 replies; 3+ messages in thread
From: FrostyBytes @ 2016-12-12 0:25 UTC (permalink / raw)
To: u-boot
I found that the latest U-Boot cannot handle filesystems generated by genext2fs. Attempts to list such a filesystem results in divide by zero.
Using git bisect with a test script, I got:
f798b1dda1c5de818b806189e523d1b75db7e72d is the first bad commit
That commit changes to using fs->gdsize rather than a calculated descriptor size.
The problem is that ext4fs_mount does not set fs->gdsize when revision_level is zero.
The simplest fix seemed to be to plug in the old calculation into the case when revision_level is zero, which made the problem go away. I know next to nothing about the internals ext2/3/4, so this may not be the right thing to do. I'm attaching a patch anyways:
The patch is also available at the following URL if the mailer has mangled it: https://ptpb.pw/KcQI
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index bfebe7e..fa83586 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -2334,6 +2334,7 @@ int ext4fs_mount(unsigned part_length)
if (le32_to_cpu(data->sblock.revision_level) == 0) {
fs->inodesz = 128;
+ fs->gdsize = EXT2_BLOCK_SIZE(data) / sizeof(struct ext2_block_group);
} else {
debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n",
__le32_to_cpu(data->sblock.feature_compatibility),
Sent with [ProtonMail](https://protonmail.com) Secure Email.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs
2016-12-12 0:25 [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs FrostyBytes
@ 2016-12-12 15:48 ` Tom Rini
2016-12-12 23:42 ` stefan.bruens at rwth-aachen.de
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-12-12 15:48 UTC (permalink / raw)
To: u-boot
On Sun, Dec 11, 2016 at 07:25:21PM -0500, FrostyBytes wrote:
> I found that the latest U-Boot cannot handle filesystems generated by genext2fs. Attempts to list such a filesystem results in divide by zero.
>
> Using git bisect with a test script, I got:
>
> f798b1dda1c5de818b806189e523d1b75db7e72d is the first bad commit
>
> That commit changes to using fs->gdsize rather than a calculated descriptor size.
>
> The problem is that ext4fs_mount does not set fs->gdsize when revision_level is zero.
>
> The simplest fix seemed to be to plug in the old calculation into the case when revision_level is zero, which made the problem go away. I know next to nothing about the internals ext2/3/4, so this may not be the right thing to do. I'm attaching a patch anyways:
>
> The patch is also available at the following URL if the mailer has mangled it: https://ptpb.pw/KcQI
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index bfebe7e..fa83586 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -2334,6 +2334,7 @@ int ext4fs_mount(unsigned part_length)
>
> if (le32_to_cpu(data->sblock.revision_level) == 0) {
> fs->inodesz = 128;
> + fs->gdsize = EXT2_BLOCK_SIZE(data) / sizeof(struct ext2_block_group);
> } else {
> debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n",
> __le32_to_cpu(data->sblock.feature_compatibility),
Thanks for looking into this and providing the fix as well. Can you
please reply back with a Signed-off-by and your real name? Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161212/c9ff6d2a/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs
2016-12-12 0:25 [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs FrostyBytes
2016-12-12 15:48 ` Tom Rini
@ 2016-12-12 23:42 ` stefan.bruens at rwth-aachen.de
1 sibling, 0 replies; 3+ messages in thread
From: stefan.bruens at rwth-aachen.de @ 2016-12-12 23:42 UTC (permalink / raw)
To: u-boot
On Sonntag, 11. Dezember 2016 19:25:21 CET FrostyBytes wrote:
> I found that the latest U-Boot cannot handle filesystems generated by
> genext2fs. Attempts to list such a filesystem results in divide by zero.
>
> Using git bisect with a test script, I got:
>
> f798b1dda1c5de818b806189e523d1b75db7e72d is the first bad commit
>
> That commit changes to using fs->gdsize rather than a calculated descriptor
> size.
>
> The problem is that ext4fs_mount does not set fs->gdsize when revision_level
> is zero.
>
> The simplest fix seemed to be to plug in the old calculation into the case
> when revision_level is zero, which made the problem go away. I know next to
> nothing about the internals ext2/3/4, so this may not be the right thing to
> do. I'm attaching a patch anyways:
>
> The patch is also available at the following URL if the mailer has mangled
> it: https://ptpb.pw/KcQI
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index bfebe7e..fa83586 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -2334,6 +2334,7 @@ int ext4fs_mount(unsigned part_length)
>
> if (le32_to_cpu(data->sblock.revision_level) == 0) {
> fs->inodesz = 128;
> + fs->gdsize = EXT2_BLOCK_SIZE(data) / sizeof(struct ext2_block_group);
> } else {
> debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n",
> __le32_to_cpu(data->sblock.feature_compatibility),
Although you are correct in that the initialization is missing here, your
patch is wrong, and may even corrupt the filesystem.
Just make it fs->gdsize = 32;
Kind regards,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-12 23:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12 0:25 [U-Boot] genext2fs fix for supporting filesystems generated by genext2fs FrostyBytes
2016-12-12 15:48 ` Tom Rini
2016-12-12 23:42 ` stefan.bruens at rwth-aachen.de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox