[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250416015106.1714709-1-Zhi.Yang@eng.windriver.com>
Date: Wed, 16 Apr 2025 09:51:06 +0800
From: Zhi Yang <Zhi.Yang@....windriver.com>
To: stable@...r.kernel.org, peili.dev@...il.com
Cc: xiangyu.chen@...driver.com, zhe.he@...driver.com, shaggy@...nel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 5.10.y] jfs: Fix shift-out-of-bounds in dbDiscardAG
From: Pei Li <peili.dev@...il.com>
commit 7063b80268e2593e58bee8a8d709c2f3ff93e2f2 upstream.
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@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61be3359d2ee3467e7e4
Signed-off-by: Pei Li <peili.dev@...il.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@...cle.com>
Signed-off-by: Zhi Yang <Zhi.Yang@...driver.com>
Signed-off-by: He Zhe <zhe.he@...driver.com>
---
Build test passed.
---
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 ef220709c7f5..ce2b18337a20 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1694,6 +1694,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 */
--
2.34.1
Powered by blists - more mailing lists