Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext4: fix error code return to user-space in ext4_get_branch()

If a block is out of range in ext4_get_branch(), -ENOMEM will be returned
to user-space. Obviously, this error code isn't really useful. This
patch fixes it by making sure the right error code (-EFSCORRUPTED) is
propagated to user-space. EUCLEAN is more informative than ENOMEM.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Link: https://lore.kernel.org/r/20221109181445.17843-1-lhenriques@suse.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org

authored by

Luís Henriques and committed by
Theodore Ts'o
26d75a16 060f7739

+8 -1
+8 -1
fs/ext4/indirect.c
··· 148 148 struct super_block *sb = inode->i_sb; 149 149 Indirect *p = chain; 150 150 struct buffer_head *bh; 151 + unsigned int key; 151 152 int ret = -EIO; 152 153 153 154 *err = 0; ··· 157 156 if (!p->key) 158 157 goto no_block; 159 158 while (--depth) { 160 - bh = sb_getblk(sb, le32_to_cpu(p->key)); 159 + key = le32_to_cpu(p->key); 160 + if (key > ext4_blocks_count(EXT4_SB(sb)->s_es)) { 161 + /* the block was out of range */ 162 + ret = -EFSCORRUPTED; 163 + goto failure; 164 + } 165 + bh = sb_getblk(sb, key); 161 166 if (unlikely(!bh)) { 162 167 ret = -ENOMEM; 163 168 goto failure;