Re: [ocfs2?] kernel BUG in ocfs2_truncate_inline
From: Edward Adam Davis
Date: Tue Oct 15 2024 - 23:30:44 EST
offset or offset + len greater than inline data max size, if true, it will
overflow in ocfs2_truncate_inline.
#syz test
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ad131a2fc58e..9327aa2f1bf4 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1784,6 +1784,12 @@ int ocfs2_remove_inode_range(struct inode *inode,
return 0;
if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
+ int max_inl = ocfs2_max_inline_data_with_xattr(inode->i_sb, di);
+ if (byte_start > max_inl || byte_start + byte_len > max_inl) {
+ ret = -EFBIG;
+ mlog_errno(ret);
+ goto out;
+ }
ret = ocfs2_truncate_inline(inode, di_bh, byte_start,
byte_start + byte_len, 0);
if (ret) {