summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 04:36:45 +0200
committerTom Rini <trini@konsulko.com>2016-09-23 09:02:37 -0400
commit10a7a1b8babbdd5684684da31482eab1931316f0 (patch)
treedf0ba5bf0a6a92dde90ce37dd943149ecd172dfb /fs/ext4
parenta321abd54fa025114df2002b33ea17adc6b998b7 (diff)
downloadu-boot-10a7a1b8babbdd5684684da31482eab1931316f0.tar.gz
u-boot-10a7a1b8babbdd5684684da31482eab1931316f0.tar.bz2
u-boot-10a7a1b8babbdd5684684da31482eab1931316f0.zip
ext4: Avoid corruption of directories with hash tree indexes
While directories can be read using the old linear scan method, adding a new file would require updating the index tree (alternatively, the whole tree could be removed). Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ext4_write.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index a52804e8e1..8554793f4f 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -881,6 +881,11 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
goto fail;
if (ext4fs_iget(parent_inodeno, g_parent_inode))
goto fail;
+ /* do not mess up a directory using hash trees */
+ if (le32_to_cpu(g_parent_inode->flags) & EXT4_INDEX_FL) {
+ printf("hash tree directory\n");
+ goto fail;
+ }
/* check if the filename is already present in root */
existing_file_inodeno = ext4fs_filename_unlink(filename);
if (existing_file_inodeno != -1) {