Bug fix for ext2.c
PATCH 1/1 Bug fix for ext2.c
Hi,
I've discovered a bug in ext2.c, inside grub_ext2_mount. The mount function must return GRUB_ERR_BAD_FS if something goes wrong, because grub_fs_probe would stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.
Signature · 1 line
Bean
fs/ext2.c +6 -6
@@ -548,17 +548,14 @@ grub_ext2_mount (grub_disk_t disk)/* Make sure this is an ext2 filesystem. */ if (grub_le_to_cpu16 (data->sblock.magic) !=EXT2_MAGIC ) - { -grub_error (GRUB_ERR_BAD_FS ,"not an ext2 filesystem" ); - goto fail; - } + goto fail;/* Check the FS doesn't have feature bits enabled that we don't support. */ if (grub_le_to_cpu32 (data->sblock.feature_incompat) & ~(EXT2_DRIVER_SUPPORTED_INCOMPAT |EXT2_DRIVER_IGNORED_INCOMPAT )) {grub_error (GRUB_ERR_BAD_FS ,"filesystem has unsupported incompatible features" ); - goto fail; + goto fail_1; }
@@ -576,7 +573,10 @@ grub_ext2_mount (grub_disk_t disk)return data; - fail: +fail: +grub_error (GRUB_ERR_BAD_FS ,"not an ext2 filesystem" ); + +fail_1:grub_free (data);return 0 ; }
Quoted 7 lines · Bean
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.
I think current behaviour is correct. If a failure is triggered by grub_disk_read(), from grub_fs_probe perspective it means something is fucked up other than just "this is not the FS we're looking for", so it should be aware of the difference.
Or is grub_ext2_read_inode() failure the one that's causing trouble for you?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 9 lines · Robert Millan
Quoted 7 lines · Bean
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.
Quoted 7 lines
I think current behaviour is correct. If a failure is triggered by
grub_disk_read(), fromgrub_fs_probeperspective it means something is fucked up other than just "this is not the FS we're looking for", so it should be aware of the difference.Or is
grub_ext2_read_inode()failure the one that's causing trouble for you?
Hi,
ext2 only reads the first two sectors in mount, which is normally ok , but there are exceptions. For example, cpio filesystem could be less one sector. Also, hostfs always return error in its read function, which would cause ext2 to fail. The effect can be seen in grub-fstest. hostfs is the first fs driver to register, and the last to query. When accessing the (host) device, ext2 cause it to fail before hostfs has a chance to see it.
Signature · 1 line
Bean
Quoted 15 lines · Bean
Quoted 14 lines · Robert Millan
Quoted 7 lines · Bean
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.I think current behaviour is correct. If a failure is triggered by
grub_disk_read(), fromgrub_fs_probeperspective it means something is fucked up other than just "this is not the FS we're looking for", so it should be aware of the difference.
Quoted 8 lines
Quoted 2 lines
Or is
grub_ext2_read_inode()failure the one that's causing trouble for you?Hi,
ext2 only reads the first two sectors in mount, which is normally ok , but there are exceptions. For example, cpio filesystem could be less one sector.
I don't understand what you mean here. If grub_disk_read failed, this indicates something's broken down in the disk layer doesn't it? How is the number of sectors related to this?
Quoted 5 lines
Also, hostfs always return error in its read function, which would cause ext2 to fail. The effect can be seen in grub-fstest. hostfs is the first fs driver to register, and the last to query. When accessing the (host) device, ext2 cause it to fail before hostfs has a chance to see it.
Why does hostfs fail? Is this intentional?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 21 lines · Robert Millan
Quoted 20 lines · Bean
Quoted 9 lines · Robert Millan
Quoted 7 lines · Bean
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.Quoted 7 lines
I think current behaviour is correct. If a failure is triggered by
grub_disk_read(), fromgrub_fs_probeperspective it means something is fucked up other than just "this is not the FS we're looking for", so it should be aware of the difference.Or is
grub_ext2_read_inode()failure the one that's causing trouble for you?Hi,
Quoted 8 lines
Quoted 3 lines
ext2 only reads the first two sectors in mount, which is normally ok , but there are exceptions. For example, cpio filesystem could be less one sector.
I don't understand what you mean here. If
grub_disk_readfailed, this indicates something's broken down in the disk layer doesn't it? How is the number of sectors related to this?
Hi,
grub_disk_read checks for disk limit. For example, cpio file system can be one sector long, trying to read two sectors would cause a out of range error.
Quoted 7 lines
Quoted 5 lines
Also, hostfs always return error in its read function, which would cause ext2 to fail. The effect can be seen in grub-fstest. hostfs is the first fs driver to register, and the last to query. When accessing the (host) device, ext2 cause it to fail before hostfs has a chance to see it.
Why does hostfs fail? Is this intentional?
Yes, it's intentional. Reading raw sectors from (host) doesn't make much sense. The (host) device is a place holder for hostfs filesystem.
Signature · 1 line
Bean
Quoted 7 lines · On Sunday 15 March 2009 01:16:23 Bean wrote:
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.
This patch ignores any kind of failure. That's a problem. If you only convert GRUB_ERR_OUT_OF_RANGE to GRUB_ERR_BAD_FS, I agree.
Regards,
Okuji
Quoted 11 lines · Yoshinori K. Okuji
Quoted 7 lines · On Sunday 15 March 2009 01:16:23 Bean wrote:
Hi,
I've discovered a bug in
ext2.c, insidegrub_ext2_mount. The mount function must returnGRUB_ERR_BAD_FSif something goes wrong, becausegrub_fs_probewould stop as soon as it sees a non-GRUB_ERR_BAD_FS error, thus preventing other fs driver from detecting the correct fs type. This patch fixes the problem.This patch ignores any kind of failure. That's a problem. If you only convert
GRUB_ERR_OUT_OF_RANGEtoGRUB_ERR_BAD_FS, I agree.
Hi,
Oh right, this one should be ok.
Signature · 1 line
Bean
fs/ext2.c +3 -0
@@ -577,6 +577,9 @@ grub_ext2_mount (grub_disk_t disk)return data; fail: +if (grub_errno ==GRUB_ERR_OUT_OF_RANGE ) +grub_error (GRUB_ERR_BAD_FS ,"not an xfs filesystem" ); +grub_free (data);return 0 ; }
Am Sonntag, den 15.03.2009, 14:00 +0800 schrieb Bean:
Quoted 1 line
Hi,
Hi Bean,
Quoted 1 line
Oh right, this one should be ok.
+ grub_error (GRUB_ERR_BAD_FS, "not an xfs filesystem");
This should probable be `not an ext2 filesystem' :)
Signature · 1 line
Felix Zielcke
Quoted 10 lines · Felix Zielcke
Am Sonntag, den 15.03.2009, 14:00 +0800 schrieb Bean:
Quoted 1 line
Hi,
Hi Bean,
Quoted 1 line
Oh right, this one should be ok.
+
grub_error(GRUB_ERR_BAD_FS, "not an xfs filesystem");
This should probable be `not an ext2 filesystem' :)
Why override grub_errmsg anyway? "not ext2" isn't going to be more useful than a "read out of range" text when displayed to the user.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 7 lines · Robert Millan
Quoted 6 lines · Felix Zielcke
Am Sonntag, den 15.03.2009, 14:00 +0800 schrieb Bean:
Quoted 1 line
Hi,
Hi Bean,
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Oh right, this one should be ok.
+ grub_error (
GRUB_ERR_BAD_FS, "not an xfs filesystem"); This should probable be `not an ext2 filesystem' :)Why override
grub_errmsganyway? "not ext2" isn't going to be more useful than a "read out of range" text when displayed to the user.
Hi,
I think the ext2 error message is better. The "read out of range" error is such a general message, it tells us little about where it goes wrong, while with "not ext2 filesystem",. we know that the error is generated in grub_ext2_mount.
Although, a more informative way is to write it like this:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem (out of range)");
But that seems a little overdo for me. Besides, fs drivers such as xfs.c, hfsplus.c use simple message for out of range error.
Signature · 1 line
Bean
Committed.
Signature · 1 line
Bean