ext4: improve error handling from ext4_dirhash()
Theodore Ts'o
maintainerPATCH 1/1 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.
Reported-by [email protected]
Signed-off-by Theodore Ts'o <[email protected]>
--- fs/ext4/hash.c | 7 ++++++- fs/ext4/namei.c | 53 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 17 deletions(-)
fs/ext4/hash.c +6 -1
@@ -277,7 +277,12 @@ 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); +WARN_ON_ONCE (1 ); +return -EINVAL ; } hash = hash & ~1 ;if (hash == (EXT4_HTREE_EOF_32BIT <<1 ))
fs/ext4/namei.c +37 -16
102 lines not on this page · raw message
Signature · 1 line
2.31.0