[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241025170010.19654-1-zoo868e@gmail.com>
Date: Sat, 26 Oct 2024 01:00:10 +0800
From: Matt Jan <zoo868e@...il.com>
To: Dave Kleikamp <shaggy@...nel.org>,
jfs-discussion@...ts.sourceforge.net,
linux-kernel@...r.kernel.org,
Shuah Khan <skhan@...uxfoundation.org>
Cc: Matt Jan <zoo868e@...il.com>,
syzbot+9e90a1c5eedb9dc4c6cc@...kaller.appspotmail.com
Subject: [PATCH v3] jfs: UBSAN: shift-out-of-bounds in dbFindBits
Return immediately if the needed free bits span a full word to avoid
out-of-bounds shifting.
#syz test
Reported-by: syzbot+9e90a1c5eedb9dc4c6cc@...kaller.appspotmail.com
Signed-off-by: Matt Jan <zoo868e@...il.com>
---
Changes in v3: Return the result earlier instead of assert it
Changes in v2: Test if the patch resolve the issue through syzbot and
reference the reporter.
fs/jfs/jfs_dmap.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 974ecf5e0d95..45b7a393b769 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -3012,6 +3012,11 @@ static int dbFindBits(u32 word, int l2nb)
int bitno, nb;
u32 mask;
+ /* return immediately if the number of free bits is a word
+ */
+ if (l2nb == BUDMIN)
+ return (!!word) << BUDMIN;
+
/* get the number of bits.
*/
nb = 1 << l2nb;
--
2.25.1
Powered by blists - more mailing lists