[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5620dcea-3c3b-424f-b24c-bd574fb8ecea@linux.alibaba.com>
Date: Wed, 16 Oct 2024 19:54:16 +0800
From: Joseph Qi <joseph.qi@...ux.alibaba.com>
To: Edward Adam Davis <eadavis@...com>, akpm <akpm@...ux-foundation.org>
Cc: jlbec@...lplan.org, l@...enly.org, linux-kernel@...r.kernel.org,
mark@...heh.com, ocfs2-devel@...ts.linux.dev,
syzbot+81092778aac03460d6b7@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH V4] ocfs2: pass u64 to ocfs2_truncate_inline maybe
overflow
On 10/16/24 7:47 PM, Joseph Qi wrote:
>
>
> On 10/16/24 7:43 PM, Edward Adam Davis wrote:
>> Syzbot reported a kernel BUG in ocfs2_truncate_inline.
>> There are two reasons for this: first, the parameter value passed is greater
>> than ocfs2_max_inline_data_with_xattr, second, the start and end parameters
>> of ocfs2_truncate_inline are "unsigned int".
>>
>> So, we need to add a sanity check for byte_start and byte_len right before
>> ocfs2_truncate_inline() in ocfs2_remove_inode_range(), if they are greater
>> than ocfs2_max_inline_data_with_xattr return -EINVAL.
>>
>> Reported-by: syzbot+81092778aac03460d6b7@...kaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=81092778aac03460d6b7
>> Signed-off-by: Edward Adam Davis <eadavis@...com>
>
> Looks fine.
> Reviewed-by: Joseph Qi <joseph.qi@...ux.alibaba.com>
>
Fixes: 1afc32b95233 ("ocfs2: Write support for inline data")
Cc: <stable@...r.kernel.org>
>> ---
>> V1 -> V2: move sanity check to ocfs2_remove_inode_range
>> V2 -> V3: use ocfs2_max_inline_data_with_xattr return value replace UINT_MAX
>> V3 -> V4: rename variable, modify return value and comments
>>
>> fs/ocfs2/file.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
>> index ad131a2fc58e..47121ee4b4df 100644
>> --- a/fs/ocfs2/file.c
>> +++ b/fs/ocfs2/file.c
>> @@ -1784,6 +1784,14 @@ int ocfs2_remove_inode_range(struct inode *inode,
>> return 0;
>>
>> if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
>> + int id_count = ocfs2_max_inline_data_with_xattr(inode->i_sb, di);
>> +
>> + if (byte_start > id_count || byte_start + byte_len > id_count) {
>> + ret = -EINVAL;
>> + mlog_errno(ret);
>> + goto out;
>> + }
>> +
>> ret = ocfs2_truncate_inline(inode, di_bh, byte_start,
>> byte_start + byte_len, 0);
>> if (ret) {
>
Powered by blists - more mailing lists