Skip to content

Commit 3562270

Browse files
Yuto Ohnukitytso
authored andcommitted
ext4: replace BUG_ON with proper error handling in ext4_read_inline_folio
Replace BUG_ON() with proper error handling when inline data size exceeds PAGE_SIZE. This prevents kernel panic and allows the system to continue running while properly reporting the filesystem corruption. The error is logged via ext4_error_inode(), the buffer head is released to prevent memory leak, and -EFSCORRUPTED is returned to indicate filesystem corruption. Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com> Link: https://patch.msgid.link/20260223123345.14838-2-ytohnuki@amazon.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent 1308255 commit 3562270

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

fs/ext4/inline.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,15 @@ static int ext4_read_inline_folio(struct inode *inode, struct folio *folio)
522522
goto out;
523523

524524
len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode));
525-
BUG_ON(len > PAGE_SIZE);
525+
526+
if (len > PAGE_SIZE) {
527+
ext4_error_inode(inode, __func__, __LINE__, 0,
528+
"inline size %zu exceeds PAGE_SIZE", len);
529+
ret = -EFSCORRUPTED;
530+
brelse(iloc.bh);
531+
goto out;
532+
}
533+
526534
kaddr = kmap_local_folio(folio, 0);
527535
ret = ext4_read_inline_data(inode, kaddr, len, &iloc);
528536
kaddr = folio_zero_tail(folio, len, kaddr + len);

0 commit comments

Comments
 (0)