summaryrefslogtreecommitdiff
path: root/fs/ext4/hash.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2023-05-06 11:59:13 -0400
committerTheodore Ts'o <tytso@mit.edu>2023-05-13 18:05:05 -0400
commit4b3cb1d108bfc2aebb0d7c8a52261a53cf7f5786 (patch)
tree4a42289a50723faacec9d4d3cd8f145b694344b4 /fs/ext4/hash.c
parenta44be64bbecb15a452496f60db6eacfee2b59c79 (diff)
ext4: improve error handling from ext4_dirhash()
The ext4_dirhash() will *almost* never fail, especially when the hash tree feature was first introduced. However, with the addition of support of encrypted, casefolded file names, that function can most certainly fail today. So make sure the callers of ext4_dirhash() properly check for failures, and reflect the errors back up to their callers. Cc: stable@kernel.org Link: https://lore.kernel.org/r/20230506142419.984260-1-tytso@mit.edu Reported-by: syzbot+394aa8a792cb99dbc837@syzkaller.appspotmail.com Reported-by: syzbot+344aaa8697ebd232bfc8@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=db56459ea4ac4a676ae4b4678f633e55da005a9b Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/hash.c')
-rw-r--r--fs/ext4/hash.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index 147b5241dd94..46c3423ddfa1 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -277,7 +277,11 @@ static int __ext4fs_dirhash(const struct inode *dir, const char *name, int len,
}
default:
hinfo->hash = 0;
- return -1;
+ hinfo->minor_hash = 0;
+ ext4_warning(dir->i_sb,
+ "invalid/unsupported hash tree version %u",
+ hinfo->hash_version);
+ return -EINVAL;
}
hash = hash & ~1;
if (hash == (EXT4_HTREE_EOF_32BIT << 1))