[SRU][J/F][PATCH 1/1] jfs: Fix shift-out-of-bounds in dbDiscardAG
Bethany Jamison
bethany.jamison at canonical.com
Wed Jan 22 20:47:03 UTC 2025
From: Pei Li <peili.dev at gmail.com>
[ 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: syzbot+61be3359d2ee3467e7e4 at syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61be3359d2ee3467e7e4
Signed-off-by: Pei Li <peili.dev at gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp at oracle.com>
Signed-off-by: Sasha Levin <sashal at kernel.org>
(cherry picked from commit bd04a149e3a29e7f71b7956ed41dba34e42d539e linux-6.1.y)
CVE-2024-44938
Signed-off-by: Bethany Jamison <bethany.jamison at canonical.com>
---
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 3fa78e5f9b21e..2906c95e837a9 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.43.0
More information about the kernel-team
mailing list