summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 04:36:45 +0200
committerDongjin Kim <tobetter@gmail.com>2020-02-10 22:44:41 +0900
commitacd2aed7df95c0e57f7d2f9ec6f938a131e60fdf (patch)
treec9e57492afb048ef087e2fee83505be3fad78798 /fs
parent0b42be160325fbd468db78871f2e103f4ea38745 (diff)
downloadu-boot-odroid-c1-acd2aed7df95c0e57f7d2f9ec6f938a131e60fdf.tar.gz
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')
-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 43afae5c37..4c255adc55 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -904,6 +904,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) {