Issue reading >4GB loopback image via grub exfat
PATCH 1/1 Issue reading >4GB loopback image via grub exfat
From: Carlo Caione <[email protected]>
We have a big image (~6GB) in an exFAT partition. We want to read the content of the image using the loopback command in grub.
What we get is an error message:
grub> loopback loop0 (hd1,gpt1)/endless/endless.img grub> ls (loop0,gpt3)/boot
error: attempt to read or write outside of disk `loop0'.
We traced this error back to the wrong type for the 'file_size' variable in the 'grub_fat_data' struct. When MODE_EXFAT is defined and grub is compiled for i386-pc, 'file_size' is still a 32bit variable when it should really be a 64bit variable to fully contain the size of the >4GB file we are dealing with.
Carlo Caione (1):
FAT/exFAT: Fix wrong size detection for files > 4GB
grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
PATCH 1/1 FAT/exFAT: Fix wrong size detection for files > 4GB
From: Carlo Caione <[email protected]>
For exFAT the file size can be > 4GB. The 'grub_fat_data' is still marking the 'file_size' as grub_ssize_t that is always 32bit when compiling for i386-pc also when using exFAT.
This is causing a problem when trying to open in loopback a > 4GB file from an exFAT partition.
Fix this modifying the size of the 'file_size' according to the MODE_EXFAT define.
--- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/fs/fat.c +5 -1
@@ -183,7 +183,11 @@ struct grub_fat_datagrub_uint32_t num_clusters;grub_uint8_t attr; -grub_ssize_t file_size; +#ifndef MODE_EXFAT +grub_uint32_t file_size; +#else +grub_uint64_t file_size; +#endif grub_uint32_t file_cluster;grub_uint32_t cur_cluster_num;grub_uint32_t cur_cluster;
Signature · 1 line
2.7.4
Re: [PATCH] FAT/exFAT: Fix wrong size detection for files > 4GB
This makes it unsigned from signed. Did you check that no code relies on signedness in fat.c?
Quoted 43 lines · Carlo Caione
From: Carlo Caione <[email protected]>
For exFAT the file size can be > 4GB. The '
grub_fat_data' is still marking the 'file_size' asgrub_ssize_tthat is always 32bit when compiling for i386-pc also when using exFAT.This is causing a problem when trying to open in loopback a > 4GB file from an exFAT partition.
Fix this modifying the size of the '
file_size' according to theMODE_EXFATdefine.Signed-off-by Carlo Caione <[email protected]>--- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)grub-core/fs/fat.c +5
-2@@ -183,7 +183,11 @@ struct grub_fat_datagrub_uint32_t num_clusters;grub_uint8_t attr; -grub_ssize_t file_size; +#ifndef MODE_EXFAT +grub_uint32_t file_size; +#else +grub_uint64_t file_size; +#endif grub_uint32_t file_cluster;grub_uint32_t cur_cluster_num;grub_uint32_t cur_cluster; --2.7.4
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] FAT/exFAT: Fix wrong size detection for files > 4GB
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
This makes it unsigned from signed. Did you check that no code relies on signedness in
fat.c?
AFAICT there is no use for the signedness in fat.c
Also, if it were the case this code would be broken in fat.c
data->file_size = ctxt.dir.file_size
since ctxt.dir.file_size is grub_uint64_t for MODE_EXFAT and grub_uint32_t for !MODE_EXFAT
Signature · 1 line
Carlo Caione | +39.340.80.30.096 | Endless
Re: [PATCH] FAT/exFAT: Fix wrong size detection for files > 4GB
In reply to Carlo Caione24.08.2016 16:36, Carlo Caione пишет:
Quoted 25 lines
From: Carlo Caione <[email protected]>
For exFAT the file size can be > 4GB. The '
grub_fat_data' is still marking the 'file_size' asgrub_ssize_tthat is always 32bit when compiling for i386-pc also when using exFAT.This is causing a problem when trying to open in loopback a > 4GB file from an exFAT partition.
Fix this modifying the size of the '
file_size' according to theMODE_EXFATdefine.Signed-off-by Carlo Caione <[email protected]>--- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)grub-core/fs/fat.c +0
-0@@ -183,7 +183,11 @@ struct grub_fat_datagrub_uint32_t num_clusters;
grub-core/fs/fat.c struct grub_fat_data · line 193
Quoted 10 lines
grub-core/fs/fat.c +5
-1grub_uint8_t attr; -grub_ssize_t file_size; +#ifndef MODE_EXFAT +grub_uint32_t file_size; +#else +grub_uint64_t file_size; +#endif grub_uint32_t file_cluster;grub_uint32_t cur_cluster_num;grub_uint32_t cur_cluster;
Looks correct except I'd use conditon "ifdef MODE_EXFAT", negative condition looks strange in such cases.
Re: [PATCH] FAT/exFAT: Fix wrong size detection for files > 4GB
Quoted 25 lines · Andrei Borzenkov
24.08.2016 16:36, Carlo Caione пишет:
Quoted 24 lines
From: Carlo Caione <[email protected]>
For exFAT the file size can be > 4GB. The '
grub_fat_data' is still marking the 'file_size' asgrub_ssize_tthat is always 32bit when compiling for i386-pc also when using exFAT.This is causing a problem when trying to open in loopback a > 4GB file from an exFAT partition.
Fix this modifying the size of the '
file_size' according to theMODE_EXFATdefine.Signed-off-by Carlo Caione <[email protected]>--- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)grub-core/fs/fat.c +0
-0@@ -183,7 +183,11 @@ struct grub_fat_datagrub_uint32_t num_clusters;
Quoted 14 lines
grub-core/fs/fat.c struct grub_fat_data · line 193
Quoted 11 lines
grub-core/fs/fat.c +5
-1grub_uint8_t attr; -grub_ssize_t file_size; +#ifndef MODE_EXFAT +grub_uint32_t file_size; +#else +grub_uint64_t file_size; +#endif grub_uint32_t file_cluster;grub_uint32_t cur_cluster_num;grub_uint32_t cur_cluster;Looks correct except I'd use conditon "ifdef
MODE_EXFAT", negative condition looks strange in such cases.
This pattern is literally used 5 lines above and all over the place in fat.c It would look strange otherwise.
Signature · 1 line
Carlo Caione | +39.340.80.30.096 | Endless
Re: [PATCH] FAT/exFAT: Fix wrong size detection for files > 4GB
Committed, thanks. Sorry for delay
Quoted 54 lines · On Thu, 25 Aug 2016, 13:52 Carlo Caione <[email protected]> wrote:
Quoted 25 lines · Andrei Borzenkov
24.08.2016 16:36, Carlo Caione пишет:
Quoted 24 lines
From: Carlo Caione <[email protected]>
For exFAT the file size can be > 4GB. The '
grub_fat_data' is still marking the 'file_size' asgrub_ssize_tthat is always 32bit when compiling for i386-pc also when using exFAT.This is causing a problem when trying to open in loopback a > 4GB file from an exFAT partition.
Fix this modifying the size of the '
file_size' according to theMODE_EXFATdefine.Signed-off-by Carlo Caione <[email protected]>--- grub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)grub-core/fs/fat.c +0
-0@@ -183,7 +183,11 @@ struct grub_fat_datagrub_uint32_t num_clusters;Quoted 14 lines
grub-core/fs/fat.c struct grub_fat_data · line 193
Quoted 11 lines
grub-core/fs/fat.c +5
-1grub_uint8_t attr; -grub_ssize_t file_size; +#ifndef MODE_EXFAT +grub_uint32_t file_size; +#else +grub_uint64_t file_size; +#endif grub_uint32_t file_cluster;grub_uint32_t cur_cluster_num;grub_uint32_t cur_cluster;Looks correct except I'd use conditon "ifdef
MODE_EXFAT", negative condition looks strange in such cases.This pattern is literally used 5 lines above and all over the place in
fat.c
It would look strange otherwise.--
Carlo Caione | +39.340.80.30.096 | Endless_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
You forgot to attach the patch
Quoted 34 lines · Carlo Caione
From: Carlo Caione <[email protected]>
We have a big image (~6GB) in an exFAT partition. We want to read the content
of the image using the loopback command in grub.What we get is an error message:
grub> loopback loop0 (hd1,gpt1)/endless/endless.img grub> ls (loop0,gpt3)/boot
error: attempt to read or write outside of disk `loop0'.We traced this error back to the wrong type for the '
file_size' variable in the
'grub_fat_data' struct. WhenMODE_EXFATis defined and grub is compiled for i386-pc, 'file_size' is still a 32bit variable when it should really be a 64bit
variable to fully contain the size of the >4GB file we are dealing with.Carlo Caione (1):
FAT/exFAT: Fix wrong size detection for files > 4GBgrub-core/fs/fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)--
2.7.4_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 1 line · Vladimir 'phcoder' Serbinenko
You forgot to attach the patch
I didn't. This is the cover letter, the patch is '[PATCH] FAT/exFAT:
Fix wrong size detection for files > 4GB'
Cheers,
Signature · 1 line
Carlo Caione | +39.340.80.30.096 | Endless