public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Remington Brasga <rbrasga@uci.edu>,
	Manas Ghandat <ghandatmanas@gmail.com>,
	Juntong Deng <juntong.deng@outlook.com>,
	Andrew Kanner <andrew.kanner@gmail.com>,
	Osama Muhammad <osmtendev@gmail.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Cc: jfs-discussion@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	syzbot+e38d703eeb410b17b473@syzkaller.appspotmail.com
Subject: Re: [PATCH] jfs: UBSAN: shift-out-of-bounds in dbFindBits
Date: Fri, 23 Aug 2024 13:16:19 -0500	[thread overview]
Message-ID: <278bfe19-4a79-4969-950a-28f9fa2fdb82@oracle.com> (raw)
In-Reply-To: <20240710001244.2707-1-rbrasga@uci.edu>

On 7/9/24 7:12PM, Remington Brasga wrote:
> Fix issue with UBSAN throwing shift-out-of-bounds warning.
> 
> Reported-by: syzbot+e38d703eeb410b17b473@syzkaller.appspotmail.com
> Signed-off-by: Remington Brasga <rbrasga@uci.edu>
> ---
> When nb = 32, `mask = mask >> nb` or shorthand `mask >>= nb` throws
> shift-out-of-bounds warning.
> `mask = (mask >> nb)` removes that warning.

Looks good. Applied.

Shaggy

> 
> Link to the syzbot bug report: https://lore.kernel.org/all/0000000000006fc563061cbc7f9c@google.com/T/
> 
>   fs/jfs/jfs_dmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
> index cb3cda1390ad..636aae946e84 100644
> --- a/fs/jfs/jfs_dmap.c
> +++ b/fs/jfs/jfs_dmap.c
> @@ -3020,7 +3020,7 @@ static int dbFindBits(u32 word, int l2nb)
>   
>   	/* scan the word for nb free bits at nb alignments.
>   	 */
> -	for (bitno = 0; mask != 0; bitno += nb, mask >>= nb) {
> +	for (bitno = 0; mask != 0; bitno += nb, mask = (mask >> nb)) {
>   		if ((mask & word) == mask)
>   			break;
>   	}

      reply	other threads:[~2024-08-23 18:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10  0:12 [PATCH] jfs: UBSAN: shift-out-of-bounds in dbFindBits Remington Brasga
2024-08-23 18:16 ` Dave Kleikamp [this message]

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=278bfe19-4a79-4969-950a-28f9fa2fdb82@oracle.com \
    --to=dave.kleikamp@oracle.com \
    --cc=andrew.kanner@gmail.com \
    --cc=ghandatmanas@gmail.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=juntong.deng@outlook.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=osmtendev@gmail.com \
    --cc=rbrasga@uci.edu \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+e38d703eeb410b17b473@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox