Re: [ocfs2?] kernel BUG in ocfs2_truncate_inline

From: Edward Adam Davis
Date: Thu Oct 10 2024 - 10:53:39 EST


offset or offset + len greater than UINT_MAX, 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..05d6a8acfcda 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1784,6 +1784,11 @@ int ocfs2_remove_inode_range(struct inode *inode,
return 0;

if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
+ if (byte_start > UINT_MAX || byte_start + byte_len > UINT_MAX) {
+ ret = -EFBIG;
+ mlog_errno(ret);
+ goto out;
+ }
ret = ocfs2_truncate_inline(inode, di_bh, byte_start,
byte_start + byte_len, 0);
if (ret) {