* [PATCH] jfs: Fix shift-out-of-bounds in dbDiscardAG
@ 2024-06-25 16:42 Pei Li
0 siblings, 0 replies; only message in thread
From: Pei Li @ 2024-06-25 16:42 UTC (permalink / raw)
To: Dave Kleikamp
Cc: jfs-discussion, linux-kernel, linux-kernel-mentees,
syzkaller-bugs, skhan, peili.dev, syzbot+61be3359d2ee3467e7e4
When searching for the next smaller log2 block, BLKSTOL2() returned 0,
causing shift exponent -1 to be negative.
This patch fixes the issue by exiting the loop directly when negative
shift is found.
Reported-by: syzbot+61be3359d2ee3467e7e4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61be3359d2ee3467e7e4
Signed-off-by: Pei Li <peili.dev@gmail.com>
---
Syzbot reported the following error:
UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:1629:18
shift exponent -1 is negative
If BLKSTOL2() returned 0, the shift exponent will be -1.
The solution is to check the exponent and if it is smaller than 0,
exit the loop directly.
---
fs/jfs/jfs_dmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cb3cda1390ad..5713994328cb 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1626,6 +1626,8 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
} else if (rc == -ENOSPC) {
/* search for next smaller log2 block */
l2nb = BLKSTOL2(nblocks) - 1;
+ if (unlikely(l2nb < 0))
+ break;
nblocks = 1LL << l2nb;
} else {
/* Trim any already allocated blocks */
---
base-commit: 2ccbdf43d5e758f8493a95252073cf9078a5fea5
change-id: 20240625-bug0-11e890f449af
Best regards,
--
Pei Li <peili.dev@gmail.com>
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-25 16:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25 16:42 [PATCH] jfs: Fix shift-out-of-bounds in dbDiscardAG Pei Li
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.