Commit b4c94b9f authored by Pei Li's avatar Pei Li Committed by ZhangPeng
Browse files

jfs: Fix shift-out-of-bounds in dbDiscardAG

stable inclusion
from stable-v6.6.47
commit f650148b43949ca9e37e820804bb6026fff404f3
bugzilla: https://gitee.com/openeuler/kernel/issues/IAHMJO

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f650148b43949ca9e37e820804bb6026fff404f3



--------------------------------

[ Upstream commit 7063b80268e2593e58bee8a8d709c2f3ff93e2f2 ]

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: default avatar <syzbot+61be3359d2ee3467e7e4@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=61be3359d2ee3467e7e4


Signed-off-by: default avatarPei Li <peili.dev@gmail.com>
Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent 65cedc14
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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 */