All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] ext4: Do not crash when trying to grow a directory using extents
Date: Thu, 18 Aug 2016 16:48:53 +0200	[thread overview]
Message-ID: <20160818164853.0502488e@amdc2363> (raw)
In-Reply-To: <538bfcea6e4d42caab3410382685e6d1@rwthex-w2-b.rwth-ad.de>

Hi Stefan,

> The following command crashes u-boot:
> ./sandbox/u-boot -c 'i=0; host bind 0 ./sandbox/test/fs/3GB.ext4.img ;
>   while test $i -lt 200 ; do echo $i; setexpr i $i + 1;
>   ext4write host 0 0 /foobar${i} 0; done'
> 
> Previously, the code updated the direct_block even for extents, and
> fortunately crashed before pushing garbage to the disk.
> 
> Signed-off-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> ---
>  fs/ext4/ext4_common.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index b8c37cf..6432104 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -431,8 +431,13 @@ restart:
>  			    sizeof(struct ext2_dirent) +
> padding_factor; if ((fs->blksz - totalbytes - last_entry_dirlen) <
>  				new_entry_byte_reqd) {
> -				printf("1st Block Full:Allocate new
> block\n");
> +				printf("Last Block Full:Allocate new
> block\n"); 
> +				if
> (le32_to_cpu(g_parent_inode->flags) &
> +						EXT4_EXTENTS_FL) {
> +					printf("Directory uses
> extents\n");
> +					goto fail;
> +				}
>  				if (direct_blk_idx ==
> INDIRECT_BLOCKS - 1) { printf("Directory exceeds limit\n");
>  					goto fail;

Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

      reply	other threads:[~2016-08-18 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160814144143.24301-1-stefan.bruens@rwth-aachen.de>
2016-08-14 14:41 ` [U-Boot] [PATCH 1/3 v2] ext4: fix possible crash on directory traversal, ignore deleted entries Stefan Brüns
2016-08-18 14:44   ` Lukasz Majewski
2016-08-14 14:41 ` [U-Boot] [PATCH 2/3] ext4: propagate error if creation of directory entry fails Stefan Brüns
2016-08-18 14:45   ` Lukasz Majewski
2016-08-14 14:41 ` [U-Boot] [PATCH 3/3] ext4: Do not crash when trying to grow a directory using extents Stefan Brüns
2016-08-18 14:48   ` Lukasz Majewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160818164853.0502488e@amdc2363 \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.