Commit 77b53030 authored by Nihar Chaithanya's avatar Nihar Chaithanya Committed by Yongjian Sun
Browse files

jfs: add a check to prevent array-index-out-of-bounds in dbAdjTree

mainline inclusion
from mainline-v6.12-rc3
commit a174706ba4dad895c40b1d2277bade16dfacdcd9
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBEAOK
CVE: CVE-2024-56595

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



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

When the value of lp is 0 at the beginning of the for loop, it will
become negative in the next assignment and we should bail out.

Reported-by: default avatar <syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=412dea214d8baa3f7483


Tested-by: default avatar <syzbot+412dea214d8baa3f7483@syzkaller.appspotmail.com>
Signed-off-by: default avatarNihar Chaithanya <niharchaithanya@gmail.com>
Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: default avatarSun Yongjian <sunyongjian1@huawei.com>
parent d51fb86c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2955,6 +2955,9 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
	/* bubble the new value up the tree as required.
	 */
	for (k = 0; k < le32_to_cpu(tp->dmt_height); k++) {
		if (lp == 0)
			break;

		/* get the index of the first leaf of the 4 leaf
		 * group containing the specified leaf (leafno).
		 */