From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Thu, 18 Aug 2016 16:48:53 +0200 Subject: [U-Boot] [PATCH 3/3] ext4: Do not crash when trying to grow a directory using extents In-Reply-To: <538bfcea6e4d42caab3410382685e6d1@rwthex-w2-b.rwth-ad.de> References: <20160814144143.24301-1-stefan.bruens@rwth-aachen.de> <538bfcea6e4d42caab3410382685e6d1@rwthex-w2-b.rwth-ad.de> Message-ID: <20160818164853.0502488e@amdc2363> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.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 > --- > 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 -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group