summaryrefslogtreecommitdiff
path: root/fs/jfs
diff options
context:
space:
mode:
authorPei Li <peili.dev@gmail.com>2024-06-25 09:42:05 -0700
committerDave Kleikamp <dave.kleikamp@oracle.com>2024-06-26 12:57:32 -0500
commit7063b80268e2593e58bee8a8d709c2f3ff93e2f2 (patch)
tree65e7d5757a64c1997eb1b340444d14622f9fa69d /fs/jfs
parentf73f969b2eb39ad8056f6c7f3a295fa2f85e313a (diff)
jfs: Fix shift-out-of-bounds in dbDiscardAG
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> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Diffstat (limited to 'fs/jfs')
-rw-r--r--fs/jfs/jfs_dmap.c2
1 files changed, 2 insertions, 0 deletions
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 */