[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <106ceb9b-0f7f-4962-98e7-d9fa86d08a0a@linux.alibaba.com>
Date: Wed, 16 Oct 2024 19:08:26 +0800
From: Joseph Qi <joseph.qi@...ux.alibaba.com>
To: Edward Adam Davis <eadavis@...com>
Cc: jlbec@...lplan.org, linux-kernel@...r.kernel.org, mark@...heh.com,
ocfs2-devel@...ts.linux.dev,
syzbot+797d4829dafe3f11dce7@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH V3] ocfs2: add a sanity check for i_size
On 10/16/24 11:52 AM, Edward Adam Davis wrote:
> On Wed, 16 Oct 2024 10:06:27 +0800, Joseph Qi wrote:
>>> Reported-and-tested-by: syzbot+797d4829dafe3f11dce7@...kaller.appspotmail.com
>>> Closes: https://syzkaller.appspot.com/bug?extid=797d4829dafe3f11dce7
>>> Signed-off-by: Edward Adam Davis <eadavis@...com>
>>> ---
>>> V1 -> V2: keep rc to 0 when falgs contains READHEAD
>>> V2 -> V3: check i_size only and alert subject and comments
>>>
>>> fs/ocfs2/extent_map.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> #syz test
>>>
>>> diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
>>> index f7672472fa82..29d27a70dbdd 100644
>>> --- a/fs/ocfs2/extent_map.c
>>> +++ b/fs/ocfs2/extent_map.c
>>> @@ -961,13 +961,17 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
>>> int rc = 0;
>>> u64 p_block, p_count;
>>> int i, count, done = 0;
>>> + loff_t i_size = i_size_read(inode);
>>>
>>> trace_ocfs2_read_virt_blocks(
>>> inode, (unsigned long long)v_block, nr, bhs, flags,
>>> validate);
>>>
>>> + if (!i_size)
>>> + return -EINVAL;
>>> +
>>
>> Take a more consideration, inode size 0 doesn't mean it has no blocks,
>> since we have a case that fallocate with KEEP_SIZE.
>> Could you please check inode->i_blocks in above coredump?
> I have previously verified the value of inode->i_blocks in my testing environment, which is 0.
>
So it seems the check condition should be:
(v_block + nr) > (inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9))
Powered by blists - more mailing lists