Commit d072d975 authored by Siddh Raman Pant's avatar Siddh Raman Pant Committed by Li Nan
Browse files

jfs: jfs_dmap: Validate db_l2nbperpage while mounting

mainline inclusion
from mainline-v6.5-rc1
commit 11509910
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9RFEZ
CVE: CVE-2023-52810

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=11509910c599cbd04585ec35a6d5e1a0053d84c1



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

In jfs_dmap.c at line 381, BLKTODMAP is used to get a logical block
number inside dbFree(). db_l2nbperpage, which is the log2 number of
blocks per page, is passed as an argument to BLKTODMAP which uses it
for shifting.

Syzbot reported a shift out-of-bounds crash because db_l2nbperpage is
too big. This happens because the large value is set without any
validation in dbMount() at line 181.

Thus, make sure that db_l2nbperpage is correct while mounting.

Max number of blocks per page = Page size / Min block size
=> log2(Max num_block per page) = log2(Page size / Min block size)
				= log2(Page size) - log2(Min block size)

=> Max db_l2nbperpage = L2PSIZE - L2MINBLOCKSIZE

Reported-and-tested-by: default avatar <syzbot+d2cd27dcf8e04b232eb2@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?id=2a70a453331db32ed491f5cbb07e81bf2d225715


Cc: stable@vger.kernel.org
Suggested-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: default avatarSiddh Raman Pant <code@siddh.me>
Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parent 5673bfb2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment