Re: [U-Boot] [PATCH v3 13/13] ext4: initialize full inode for inodes bigger than 128 bytes

2016-09-05 Thread Stefan Bruens
On Sonntag, 28. August 2016 22:42:38 CEST you wrote:
> Make sure the the extra_isize field (offset 128) is initialized to 0 to
> mark any extra data as invalid.
> 
> Signed-off-by: Stefan Brüns 
> ---
>  fs/ext4/ext4_write.c | 12 +---
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> v3: Patch added to series
> 
> diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
> index 81a750b..38fbf68 100644
> --- a/fs/ext4/ext4_write.c
> +++ b/fs/ext4/ext4_write.c
> @@ -454,7 +454,7 @@ static int ext4fs_delete_file(int inodeno)
>   node_inode->data = ext4fs_root;
>   node_inode->ino = inodeno;
>   node_inode->inode_read = 0;
> - memcpy(&(node_inode->inode), , sizeof(struct ext2_inode));
> + memcpy(&(node_inode->inode), , fs->inodesz);
This line is actually broken, node_inode->inode is sizeof(struct ext2_inode), 
i.e 128 bytes. It is responsible for the crash Thomas reported.

Kind regards,

Stefan 
-- 
Stefan Brüns  /  Bergstraße 21  /  52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
work: +49 2405 49936-424
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 13/13] ext4: initialize full inode for inodes bigger than 128 bytes

2016-08-29 Thread Lukasz Majewski
Hi Stefan,

> Make sure the the extra_isize field (offset 128) is initialized to 0
^^^ that ?

> to mark any extra data as invalid.
> 
> Signed-off-by: Stefan Brüns 
> ---
>  fs/ext4/ext4_write.c | 12 +---
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> v3: Patch added to series
> 
> diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
> index 81a750b..38fbf68 100644
> --- a/fs/ext4/ext4_write.c
> +++ b/fs/ext4/ext4_write.c
> @@ -454,7 +454,7 @@ static int ext4fs_delete_file(int inodeno)
>   node_inode->data = ext4fs_root;
>   node_inode->ino = inodeno;
>   node_inode->inode_read = 0;
> - memcpy(&(node_inode->inode), , sizeof(struct
> ext2_inode));
> + memcpy(&(node_inode->inode), , fs->inodesz);
>  
>   for (i = 0; i < no_blocks; i++) {
>   blknr =
> read_allocated_block(&(node_inode->inode), i); @@ -560,7 +560,7 @@
> static int ext4fs_delete_file(int inodeno) 
>   read_buffer = read_buffer + blkoff;
>   inode_buffer = (struct ext2_inode *)read_buffer;
> - memset(inode_buffer, '\0', sizeof(struct ext2_inode));
> + memset(inode_buffer, '\0', fs->inodesz);
>  
>   /* write the inode to original position in inode table */
>   if (ext4fs_put_metadata(start_block_address, blkno))
> @@ -866,7 +866,7 @@ int ext4fs_write(const char *fname, unsigned char
> *buffer, ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
>   memset(filename, 0x00, 256);
>  
> - g_parent_inode = zalloc(sizeof(struct ext2_inode));
> + g_parent_inode = zalloc(fs->inodesz);
>   if (!g_parent_inode)
>   goto fail;
>  
> @@ -969,8 +969,7 @@ int ext4fs_write(const char *fname, unsigned char
> *buffer, if (ext4fs_log_journal(temp_ptr, parent_itable_blkno))
>   goto fail;
>  
> - memcpy(temp_ptr + blkoff, g_parent_inode,
> - sizeof(struct ext2_inode));
> + memcpy(temp_ptr + blkoff, g_parent_inode,
> fs->inodesz); if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
>   goto fail;
>   } else {
> @@ -978,8 +977,7 @@ int ext4fs_write(const char *fname, unsigned char
> *buffer,
>* If parent and child fall in same inode table block
>* both should be kept in 1 buffer
>*/
> - memcpy(temp_ptr + blkoff, g_parent_inode,
> -sizeof(struct ext2_inode));
> + memcpy(temp_ptr + blkoff, g_parent_inode,
> fs->inodesz); gd_index--;
>   if (ext4fs_put_metadata(temp_ptr, itable_blkno))
>   goto fail;

Reviewed-by: Lukasz Majewski  

-- 
Best regards,

Lukasz Majewski

Samsung R Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 13/13] ext4: initialize full inode for inodes bigger than 128 bytes

2016-08-28 Thread Stefan Brüns
Make sure the the extra_isize field (offset 128) is initialized to 0 to
mark any extra data as invalid.

Signed-off-by: Stefan Brüns 
---
 fs/ext4/ext4_write.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

v3: Patch added to series

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 81a750b..38fbf68 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -454,7 +454,7 @@ static int ext4fs_delete_file(int inodeno)
node_inode->data = ext4fs_root;
node_inode->ino = inodeno;
node_inode->inode_read = 0;
-   memcpy(&(node_inode->inode), , sizeof(struct ext2_inode));
+   memcpy(&(node_inode->inode), , fs->inodesz);
 
for (i = 0; i < no_blocks; i++) {
blknr = read_allocated_block(&(node_inode->inode), i);
@@ -560,7 +560,7 @@ static int ext4fs_delete_file(int inodeno)
 
read_buffer = read_buffer + blkoff;
inode_buffer = (struct ext2_inode *)read_buffer;
-   memset(inode_buffer, '\0', sizeof(struct ext2_inode));
+   memset(inode_buffer, '\0', fs->inodesz);
 
/* write the inode to original position in inode table */
if (ext4fs_put_metadata(start_block_address, blkno))
@@ -866,7 +866,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
memset(filename, 0x00, 256);
 
-   g_parent_inode = zalloc(sizeof(struct ext2_inode));
+   g_parent_inode = zalloc(fs->inodesz);
if (!g_parent_inode)
goto fail;
 
@@ -969,8 +969,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
if (ext4fs_log_journal(temp_ptr, parent_itable_blkno))
goto fail;
 
-   memcpy(temp_ptr + blkoff, g_parent_inode,
-   sizeof(struct ext2_inode));
+   memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
goto fail;
} else {
@@ -978,8 +977,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
 * If parent and child fall in same inode table block
 * both should be kept in 1 buffer
 */
-   memcpy(temp_ptr + blkoff, g_parent_inode,
-  sizeof(struct ext2_inode));
+   memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
gd_index--;
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;
-- 
2.9.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot