ext4fs: le32_to_cpu() used on a 16-bit field
RFC 1/1 ext4fs: le32_to_cpu() used on a 16-bit field
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit but le32_to_cpu() is used. Some checks (ie eh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.
Does these seem right? Or am I mistaken?
-----
fs/ext4/ext4_common.c +0 -0
@@ -1429,7 +1429,7 @@ static struct ext4_extent_header
*ext4fs_get_extent_block
while (1) {
index = (struct ext4_extent_idx *)(ext_block + 1);
- if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
+ if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
return 0;
if (ext_block->eh_depth == 0)
@@ -1437,14 +1437,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block
i = -1;
do {
i++;
- if (i >= le32_to_cpu(ext_block->eh_entries))
+ if (i >= le16_to_cpu(ext_block->eh_entries))
break;
} while (fileblock > le32_to_cpu(index[i].ei_block));
if (--i < 0)
return 0;
- block = le32_to_cpu(index[i].ei_leaf_hi);
+ block = le16_to_cpu(index[i].ei_leaf_hi);
block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);
if (ext4fs_devread(block << log2_blksz, 0, fs->blksz, buf))
@@ -1543,17 +1543,17 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock)
do {
i++;
- if (i >= le32_to_cpu(ext_block->eh_entries))
+ if (i >= le16_to_cpu(ext_block->eh_entries))
break;
} while (fileblock >= le32_to_cpu(extent[i].ee_block)); if (--i >= 0) {
fileblock -= le32_to_cpu(extent[i].ee_block);
- if (fileblock >= le32_to_cpu(extent[i].ee_len)) {
+ if (fileblock >= le16_to_cpu(extent[i].ee_len)) {
free(buf);
return 0;
}
- start = le32_to_cpu(extent[i].ee_start_hi);
+ start = le16_to_cpu(extent[i].ee_start_hi);
start = (start << 32) +
le32_to_cpu(extent[i].ee_start_lo);
free(buf);
-----
(Sorry, I can't CC anyone directly as I'm using the gmane "post" interface)
All the best,
Rommel
Hi Rommel,
Quoted 7 lines
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
The ext4 code at u-boot (especially ext4write) needs special attention.
It is on top of my list to refactor and clean up this code base (especially the ext4write command).
Quoted 7 lines
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
I would need to double check it (since I'm using only ext4load at my target board currently).
Quoted 18 lines
-----
fs/ext4/ext4_common.c +1
-1@@ -1429,7 +1429,7 @@ static struct ext4_extent_header *ext4fs_get_extent_blockwhile (1 ) { index = (struct ext4_extent_idx *)(ext_block +1 ); -if (le32_to_cpu (ext_block->eh_magic) != EXT4_EXT_MAGIC) +if (le16_to_cpu (ext_block->eh_magic) !=EXT4_EXT_MAGIC )return 0 ;fs/ext4/ext4_common.c +0
-0if (ext_block->eh_depth ==0 )
fs/ext4/ext4_common.c static struct ext4_extent_header · line 1441
Quoted 6 lines
fs/ext4/ext4_common.c +1
-1@@ -1437,14 +1437,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block i = -1; do { i++; - if (i >= le32_to_cpu(ext_block->eh_entries)) + if (i >= le16_to_cpu(ext_block->eh_entries))
^^^^^ We had some problems with unaligned access to 16 bit values recently (when those start at 0x2). It was observed on our ARM Exynos4 based target.
Quoted 36 lines
fs/ext4/ext4_common.c +1
-1break ; }while (fileblock >le32_to_cpu (index[i].ei_block));if (--i <0 )return 0 ; - block =le32_to_cpu (index[i].ei_leaf_hi); + block =le16_to_cpu (index[i].ei_leaf_hi); block = (block <<32 ) +le32_to_cpu (index[i].ei_leaf_lo);if (ext4fs_devread(block <<
log2_blksz, 0,fs->blksz, buf)) @@ -1543,17 +1543,17 @@ long intread_allocated_block(struct ext2_inode *inode, int fileblock)fs/ext4/ext4_common.c +1
-1do { i++; - if (i >= le32_to_cpu(ext_block->eh_entries)) + if (i >= le16_to_cpu(ext_block->eh_entries)) break; } while (fileblock >=
le32_to_cpu(extent[i].ee_block)); if (--i >= 0) {fs/ext4/ext4_common.c +0
-1fileblock -=le32_to_cpu (extent[i].ee_block); - if (fileblock >=
le32_to_cpu(extent[i].ee_len)) {fs/ext4/ext4_common.c +1
-0+ if (fileblock >=
le16_to_cpu(extent[i].ee_len)) { free(buf);fs/ext4/ext4_common.c +1
-2return 0 ; } - start =le32_to_cpu (extent[i].ee_start_hi); + start =le16_to_cpu (extent[i].ee_start_hi); start = (start <<32 ) +le32_to_cpu (extent[i].ee_start_lo);free (buf); -----
Quoted 2 lines
(Sorry, I can't CC anyone directly as I'm using the gmane "post" interface)
You can also CC ext4 u-boot's implementation authors.
Quoted 9 lines
All the best,
Rommel_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sorry for the extra noise.
Quoted 39 lines · Rommel G Custodio
Dear Lukasz Majewski,
Quoted 6 lines · Lukasz Majewski
Hi Rommel,
Quoted 4 lines
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Quoted 9 lines
Quoted 3 lines
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
The ext4 code at u-boot (especially ext4write) needs special attention.
It is on top of my list to refactor and clean up this code base (especially the ext4write command).
I know the code is fairly recent and it seems limited testing (on a limited number of platforms) has only been performed.
Quoted 11 lines
Quoted 7 lines
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
I would need to double check it (since I'm using only ext4load at my target board currently).
Without the patches below ext4load/ext2load doesn't work correctly on the ml507.
For testing, the default settings are used enabled). The SD card mounts correctly using ext4 in Linux but I get this error in u-boot:
Quoted 31 lines
ml507:/# ext4ls mmc 0:1 <DIR> 4096 . <DIR> 4096 .. <DIR> 16384 lost+found 9294153 mybit.ace ml507:/# ext2ls mmc 0:1 <DIR> 4096 . <DIR> 4096 .. <DIR> 16384 lost+found 9294153 mybit.ace ml507:/# ext4load mmc 0:1 1000000 /mybit.ace invalid extent block ml507:/# ext2load mmc 0:1 1000000 mybit.ace invalid extent blockQuoted 16 lines
Review
Quoted 4 lines
do { i++;(quoted diff) +1
-1- if (i >= le32_to_cpu(ext_block->eh_entries)) + if (i >= le16_to_cpu(ext_block->eh_entries))^^^^^ We had some problems with unaligned access to 16 bit values recently (when those start at
0x2). It was observed on our ARM Exynos4 based target.Quoted 3 lines
(Sorry, I can't CC anyone directly as I'm using the gmane "post" interface)
You can also CC ext4 u-boot's implementation authors.
Forgot to Cc the list
And the original author's email seem to be bouncing.
Quoted 20 lines
Quoted 19 lines
Quoted 10 lines
All the best,
Rommel_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot--
Best regards,Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
On Tue, 16 Jul 2013 08:14:35 +0000 (UTC) Rommel Custodio sessyargc+uboot at gmail.com wrote,
Hi Rommel,
Quoted 8 lines
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
Quoted 6 lines
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
What kind of mailer program have you used to sent this e-mail? I receive following errors:
fatal: corrupt patch at line 111
I cannot apply this patch with either git am -3 or git apply.
Were you using git send-email?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH RESEND 1/1 ext4fs: le32_to_cpu() used on a 16-bit field
Dear Lukasz Majewski
Quoted 3 lines · Lukasz Majewski
fatal: corrupt patch at line 111
I cannot apply this patch with either git am -3 or git apply.
I'm resending the patch.
Quoted 2 lines
Quoted 2 lines
(Sorry, I can't CC anyone directly as I'm using the gmane "post" interface)
All the best,
Rommel
--- fs/ext4/ext4_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/ext4/ext4_common.c +6 -6
@@ -1432,7 +1432,7 @@ static struct ext4_extent_header *ext4fs_get_extent_blockwhile (1 ) { index = (struct ext4_extent_idx *)(ext_block +1 ); -if (le32_to_cpu (ext_block->eh_magic) !=EXT4_EXT_MAGIC ) +if (le16_to_cpu (ext_block->eh_magic) !=EXT4_EXT_MAGIC )return 0 ;if (ext_block->eh_depth ==0 )
@@ -1440,14 +1440,14 @@ static struct ext4_extent_header *ext4fs_get_extent_block i =-1 ;do { i++; -if (i >=le32_to_cpu (ext_block->eh_entries)) +if (i >=le16_to_cpu (ext_block->eh_entries))break ; }while (fileblock >le32_to_cpu (index[i].ei_block));if (--i <0 )return 0 ; - block =le32_to_cpu (index[i].ei_leaf_hi); + block =le16_to_cpu (index[i].ei_leaf_hi); block = (block <<32 ) +le32_to_cpu (index[i].ei_leaf_lo); if (ext4fs_devread((lbaint_t)block << log2_blksz, 0, fs->blksz,
@@ -1548,17 +1548,17 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock)do { i++; -if (i >=le32_to_cpu (ext_block->eh_entries)) +if (i >=le16_to_cpu (ext_block->eh_entries))break ; }while (fileblock >=le32_to_cpu (extent[i].ee_block));if (--i >=0 ) { fileblock -=le32_to_cpu (extent[i].ee_block); -if (fileblock >=le32_to_cpu (extent[i].ee_len)) { +if (fileblock >=le16_to_cpu (extent[i].ee_len)) {free (buf);return 0 ; } - start =le32_to_cpu (extent[i].ee_start_hi); + start =le16_to_cpu (extent[i].ee_start_hi); start = (start <<32 ) +le32_to_cpu (extent[i].ee_start_lo);free (buf);
Signature · 1 line
1.8.3.3
+Tom
Quoted 20 lines · Lukasz Majewski
On Tue, 16 Jul 2013 08:14:35 +0000 (UTC) Rommel Custodio sessyargc+uboot at gmail.com wrote,
Hi Rommel,
Quoted 8 lines
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
Quoted 6 lines
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
Quoted 9 lines
What kind of mailer program have you used to sent this e-mail? I receive following errors:
fatal: corrupt patch at line 111
I cannot apply this patch with either git am -3 or git apply.
Were you using git send-email?
It seems like we should try to fix this before the release?
Regards,
Simon
Hi all,
Quoted 27 lines · Simon Glass
+Tom
Quoted 23 lines · Lukasz Majewski
On Tue, 16 Jul 2013 08:14:35 +0000 (UTC) Rommel Custodio sessyargc+uboot at gmail.com wrote,
Hi Rommel,
Quoted 8 lines
Hi All,
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
Quoted 6 lines
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
What kind of mailer program have you used to sent this e-mail? I receive following errors:
Quoted 8 lines
Quoted 6 lines
fatal: corrupt patch at line 111
I cannot apply this patch with either git am -3 or git apply.
Were you using git send-email?
It seems like we should try to fix this before the release?
+1
I can confirm that reading ext4 extended header on BE machine (avr32) is broken. I'm currently on it to get it working by using Rommel's patch.
Regards
Andreas Bie?mann
Hi!
Quoted 11 lines
U-Boot 2013.07-rc3 [ELDK 5.2.1 / ELDK 5.3]
Now I've started to use the new ext4 code. I need the "ext4write" command. Though there seems to be several problems with the ext2/ext4 code.
I am testing on an ml507 (PPC440, Big Endian).
There are some cases where the a field is 16-bit butle32_to_cpu()is used. Some checks (ieeh_magic) fails to match even if I use a correctly ext4 formatted MMC/SD card.Does these seem right? Or am I mistaken?
This fixed ext4 on powerpc-based board. Thanks!
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html