summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJuntong Deng <juntong.deng@outlook.com>2023-10-02 12:56:58 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-28 19:46:32 +0300
commit8f2964df6bfce9d92d81ca552010b8677af8d9dc (patch)
tree028f9160c86aed565fd1de005452a66a0b339b8f /fs
parentf585da5c274f93926845bf54199dc618b617c743 (diff)
downloadlinux-8f2964df6bfce9d92d81ca552010b8677af8d9dc.tar.xz
fs/jfs: Add check for negative db_l2nbperpage
[ Upstream commit 525b861a008143048535011f3816d407940f4bfa ] l2nbperpage is log2(number of blks per page), and the minimum legal value should be 0, not negative. In the case of l2nbperpage being negative, an error will occur when subsequently used as shift exponent. Syzbot reported this bug: UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:799:12 shift exponent -16777216 is negative Reported-by: syzbot+debee9ab7ae2b34b0307@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=debee9ab7ae2b34b0307 Signed-off-by: Juntong Deng <juntong.deng@outlook.com> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jfs/jfs_dmap.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index b20fffc8b4c1..5e20d7270d5f 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -193,7 +193,8 @@ int dbMount(struct inode *ipbmap)
bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
- if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) {
+ if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE ||
+ bmp->db_l2nbperpage < 0) {
err = -EINVAL;
goto err_release_metapage;
}