Skip to content

Commit 7063b80

Browse files
peiliikleikamp
authored andcommitted
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>
1 parent f73f969 commit 7063b80

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/jfs/jfs_dmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,8 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
16261626
} else if (rc == -ENOSPC) {
16271627
/* search for next smaller log2 block */
16281628
l2nb = BLKSTOL2(nblocks) - 1;
1629+
if (unlikely(l2nb < 0))
1630+
break;
16291631
nblocks = 1LL << l2nb;
16301632
} else {
16311633
/* Trim any already allocated blocks */

0 commit comments

Comments
 (0)