summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 04:36:43 +0200
committerDongjin Kim <tobetter@gmail.com>2020-02-10 22:44:41 +0900
commitb969f29b9f0735d57c2ad416698346603a9403f3 (patch)
tree6409ec0f10d330ff5f0a8aa50adeca443c9429a7 /fs
parente48c74b56e8f682416633d8a0c6392a31e2c71de (diff)
downloadu-boot-odroid-c1-b969f29b9f0735d57c2ad416698346603a9403f3.tar.gz
ext4: Do not crash when trying to grow a directory using extents
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> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4_common.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index efca8d5828..9ab595ed97 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -461,8 +461,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;