Commit b96c3c7292214fb81b1b355bf5a6d53cf9996d1e
Committed by
Tom Rini
1 parent
a0d767e2c1
Exists in
v2017.01-smarct4x
and in
25 other branches
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>
Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff
fs/ext4/ext4_common.c
... | ... | @@ -453,8 +453,13 @@ |
453 | 453 | sizeof(struct ext2_dirent) + padding_factor; |
454 | 454 | if ((fs->blksz - totalbytes - last_entry_dirlen) < |
455 | 455 | new_entry_byte_reqd) { |
456 | - printf("1st Block Full:Allocate new block\n"); | |
456 | + printf("Last Block Full:Allocate new block\n"); | |
457 | 457 | |
458 | + if (le32_to_cpu(g_parent_inode->flags) & | |
459 | + EXT4_EXTENTS_FL) { | |
460 | + printf("Directory uses extents\n"); | |
461 | + goto fail; | |
462 | + } | |
458 | 463 | if (direct_blk_idx == INDIRECT_BLOCKS - 1) { |
459 | 464 | printf("Directory exceeds limit\n"); |
460 | 465 | goto fail; |