All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Heming Zhao <heming.zhao@suse.com>, qasdev <qasdev00@gmail.com>,
	mark@fasheh.com, jlbec@evilplan.org
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ocfs2: Fix shift-out-of-bounds UBSAN bug in ocfs2_verify_volume()
Date: Mon, 19 Aug 2024 10:52:29 +0800	[thread overview]
Message-ID: <e5fb0013-ea4e-4da7-89e5-6b2b0879ecc9@linux.alibaba.com> (raw)
In-Reply-To: <cbd30b80-d213-4997-b447-10e455f20196@suse.com>



On 8/18/24 7:43 PM, Heming Zhao wrote:
> On 8/16/24 21:41, qasdev wrote:
>>  From ad1ca2fd2ecf4eb7ec2c76fcbbf34639f0ad87ca Mon Sep 17 00:00:00 2001
>> From: Qasim Ijaz <qasdev00@gmail.com>
>> Date: Fri, 16 Aug 2024 02:30:25 +0100
>> Subject: [PATCH] ocfs2: Fix shift-out-of-bounds UBSAN bug in
>>   ocfs2_verify_volume()
>>

The above should be eliminated from patch body. 

>> This patch addresses a shift-out-of-bounds error in the
>> ocfs2_verify_volume() function, identified by UBSAN. The bug was triggered
>> by an invalid s_clustersize_bits value (e.g., 1548), which caused the
>> expression "1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits)"
>> to exceed the limits of a 32-bit integer,
>> leading to an out-of-bounds shift.
>>
>> Reported-by: syzbot <syzbot+f3fff775402751ebb471@syzkaller.appspotmail.com>
>> Closes: https://syzkaller.appspot.com/bug?extid=f3fff775402751ebb471
>> Tested-by: syzbot <syzbot+f3fff775402751ebb471@syzkaller.appspotmail.com>
>> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
>> ---
>>   fs/ocfs2/super.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
>> index afee70125ae3..1e43cdca7f40 100644
>> --- a/fs/ocfs2/super.c
>> +++ b/fs/ocfs2/super.c
>> @@ -2357,8 +2357,12 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
>>                    (unsigned long long)bh->b_blocknr);
>>           } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
>>                   le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
>> -            mlog(ML_ERROR, "bad cluster size found: %u\n",
>> -                 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits));
>> +            if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 32)
>> +                mlog(ML_ERROR, "bad cluster size found: %u\n",
>> +                     1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits));
>> +            else
>> +                mlog(ML_ERROR, "invalid cluster size bit value: %u\n",
>> +                     le32_to_cpu(di->id2.i_super.s_clustersize_bits));
> 
> I prefer to use concise code to fix the error.
> Do you like below code?
> -        mlog(ML_ERROR, "bad cluster size found: %u\n",
> -                 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits));
> +        mlog(ML_ERROR, "bad cluster size bit found: %u\n",
> +                 le32_to_cpu(di->id2.i_super.s_clustersize_bits));
> 

Agree. qasdev, Could you please update and send v2?

Thanks,
Joseph

  reply	other threads:[~2024-08-19  2:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 13:41 [PATCH] ocfs2: Fix shift-out-of-bounds UBSAN bug in ocfs2_verify_volume() qasdev
2024-08-18 11:43 ` Heming Zhao
2024-08-19  2:52   ` Joseph Qi [this message]
2024-08-20  1:03     ` [PATCH v2] " qasdev
2024-08-20  1:12       ` Joseph Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5fb0013-ea4e-4da7-89e5-6b2b0879ecc9@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=heming.zhao@suse.com \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=qasdev00@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.