public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: darklight2357@gmail.com
Cc: aha310510@gmail.com, linux-kernel@vger.kernel.org,
	syzbot+13e8cd4926977f8337b6@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [jfs?] UBSAN: shift-out-of-bounds in extAlloc (2)
Date: Sat,  1 Jun 2024 11:56:07 +0900	[thread overview]
Message-ID: <20240601025607.22180-1-aha310510@gmail.com> (raw)
In-Reply-To: <CAJDnv3bHUUPT10O6_M64vNXXKuvAQMGEpzQs1XQvEHpGXS0zCQ@mail.gmail.com>

Hi,

Thanks to the points you pointed out, I was able to confirm that there
was a rudimentary mistake in my patch. And as you suggested, I think
it would be a good idea to handle the two situations separately.

However, if you only check when there is a value of sizeof(s64) * 8 or
more in bmp->db_maxfreebud, the value will change to a negative number
when bmp->db_maxfreebud is 63 because max is an s64 data type. 
Therefore, I think it is right to slightly modify the conditions.

Regards.

---
 fs/jfs/jfs_extent.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c
index 63d21822d309..3d1273d35b13 100644
--- a/fs/jfs/jfs_extent.c
+++ b/fs/jfs/jfs_extent.c
@@ -316,6 +316,9 @@ extBalloc(struct inode *ip, s64 hint, s64 * nblocks, s64 * blkno)
        if (bmp->db_maxfreebud == -1)
                return -ENOSPC;
 
+       if (bmp->db_maxfreebud >= sizeof(s64) * 8 - 1)
+               return -EINVAL;
+
        max = (s64) 1 << bmp->db_maxfreebud;
        if (*nblocks >= max && *nblocks > nbperpage)
                nb = nblks = (max > nbperpage) ? max : nbperpage;
-- 
2.34.1

  reply	other threads:[~2024-06-01  2:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 13:40 [syzbot] [jfs?] UBSAN: shift-out-of-bounds in extAlloc (2) syzbot
2024-05-31 11:06 ` Jeongjun Park
2024-05-31 18:18   ` syzbot
2024-06-01  0:29   ` Changheon LEE
2024-06-01  2:56     ` Jeongjun Park [this message]
2024-06-01  3:00 ` Jeongjun Park
2024-06-01  3:31   ` syzbot
2025-09-28  2:54 ` Forwarded: " syzbot
     [not found] <87zfafi8w9.fsf@gmail.com>
2025-09-28  3:16 ` syzbot

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=20240601025607.22180-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=darklight2357@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+13e8cd4926977f8337b6@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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