Re: [ocfs2?] kernel BUG in ocfs2_read_virt_blocks
From: Edward Adam Davis
Date: Sun Oct 13 2024 - 02:32:40 EST
if the value of flags is 0, it is meaningless to check it contains OCFS2_BH_READAHEAD
#syz test
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index f7672472fa82..0043c2428ef2 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -968,7 +968,8 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
if (((v_block + nr - 1) << inode->i_sb->s_blocksize_bits) >=
i_size_read(inode)) {
- BUG_ON(!(flags & OCFS2_BH_READAHEAD));
+ BUG_ON(flags && !(flags & OCFS2_BH_READAHEAD));
+ rc = flags ?: -EIO;
goto out;
}