Skip to content

Commit 099b847

Browse files
committed
ext4: do not BUG when INLINE_DATA_FL lacks system.data xattr
A syzbot fuzzed image triggered a BUG_ON in ext4_update_inline_data() when an inode had the INLINE_DATA_FL flag set but was missing the system.data extended attribute. Since this can happen due to a maiciouly fuzzed file system, we shouldn't BUG, but rather, report it as a corrupted file system. Add similar replacements of BUG_ON with EXT4_ERROR_INODE() ii ext4_create_inline_data() and ext4_inline_data_truncate(). Reported-by: [email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent a3ce570 commit 099b847

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

fs/ext4/inline.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ static int ext4_create_inline_data(handle_t *handle,
303303
if (error)
304304
goto out;
305305

306-
BUG_ON(!is.s.not_found);
306+
if (!is.s.not_found) {
307+
EXT4_ERROR_INODE(inode, "unexpected inline data xattr");
308+
error = -EFSCORRUPTED;
309+
goto out;
310+
}
307311

308312
error = ext4_xattr_ibody_set(handle, inode, &i, &is);
309313
if (error) {
@@ -354,7 +358,11 @@ static int ext4_update_inline_data(handle_t *handle, struct inode *inode,
354358
if (error)
355359
goto out;
356360

357-
BUG_ON(is.s.not_found);
361+
if (is.s.not_found) {
362+
EXT4_ERROR_INODE(inode, "missing inline data xattr");
363+
error = -EFSCORRUPTED;
364+
goto out;
365+
}
358366

359367
len -= EXT4_MIN_INLINE_DATA_SIZE;
360368
value = kzalloc(len, GFP_NOFS);
@@ -1869,7 +1877,12 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)
18691877
if ((err = ext4_xattr_ibody_find(inode, &i, &is)) != 0)
18701878
goto out_error;
18711879

1872-
BUG_ON(is.s.not_found);
1880+
if (is.s.not_found) {
1881+
EXT4_ERROR_INODE(inode,
1882+
"missing inline data xattr");
1883+
err = -EFSCORRUPTED;
1884+
goto out_error;
1885+
}
18731886

18741887
value_len = le32_to_cpu(is.s.here->e_value_size);
18751888
value = kmalloc(value_len, GFP_NOFS);

0 commit comments

Comments
 (0)