From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E038C1E103C; Wed, 6 Nov 2024 13:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730898400; cv=none; b=qZfGtqQAL1tQ9R5k6NvVPAStg8RzdbJPNgCyQSeRrt8COoSnhMy0KO8iu68QmV2t9jYXW2BGgBop5zZ33CprQOpVu+/QY2YInlTM+d2Uzq10QE+0RKGKsKL1Frkn0b1PTs7pof8dImqixyC4amJt73G7ZqiI//wzUgDrxMQW7T8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730898400; c=relaxed/simple; bh=gURm09B3k6j57uoS508bTkLSbfkgRHjYnX5cx4Y7u5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q+ZUVuaKZ+Yeu3bnRFrFdlhZwyXS72htwKgbhxzha5tLC+5HuuTnQLBbutyjdfJbYz/yQHJSFg/uLJWrPNp8Fuwl7fNJGVBnp3p4EMP4cScIG7+6FXALxRHGp5UlTObBhPtBFac6uVDaPZt4eLIrSHHG0j9HW6zIqpy0MSdeGRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2UMFC4Rj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2UMFC4Rj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21DB4C4CECD; Wed, 6 Nov 2024 13:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730898399; bh=gURm09B3k6j57uoS508bTkLSbfkgRHjYnX5cx4Y7u5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2UMFC4RjQvvsCIvNui5zdurJMJIFdcmIl+Z4J/OWQ1nOjxO/4syLL/Z6Zq2b0ME+T J44+8LLjMgQmmZEeaCdbd9DI5X0sJE5Kpqb6tydxyurpZotsYg1Ndw5szQnWNGshlc JguTA5I+/EBMgyMwQJ/Tu3QiO2UHtD+buquHOo4w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Edward Adam Davis , Dave Kleikamp , Sasha Levin , syzbot+dca05492eff41f604890@syzkaller.appspotmail.com Subject: [PATCH 5.4 224/462] jfs: check if leafidx greater than num leaves per dmap tree Date: Wed, 6 Nov 2024 13:01:57 +0100 Message-ID: <20241106120337.053300383@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120331.497003148@linuxfoundation.org> References: <20241106120331.497003148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Edward Adam Davis [ Upstream commit d64ff0d2306713ff084d4b09f84ed1a8c75ecc32 ] syzbot report a out of bounds in dbSplit, it because dmt_leafidx greater than num leaves per dmap tree, add a checking for dmt_leafidx in dbFindLeaf. Shaggy: Modified sanity check to apply to control pages as well as leaf pages. Reported-and-tested-by: syzbot+dca05492eff41f604890@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=dca05492eff41f604890 Signed-off-by: Edward Adam Davis Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/jfs_dmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index ab90c7561e20c..01cdfe7891b94 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -3006,9 +3006,10 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl) static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl) { int ti, n = 0, k, x = 0; - int max_size; + int max_size, max_idx; max_size = is_ctl ? CTLTREESIZE : TREESIZE; + max_idx = is_ctl ? LPERCTL : LPERDMAP; /* first check the root of the tree to see if there is * sufficient free space. @@ -3040,6 +3041,8 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl) */ assert(n < 4); } + if (le32_to_cpu(tp->dmt_leafidx) >= max_idx) + return -ENOSPC; /* set the return to the leftmost leaf describing sufficient * free space. -- 2.43.0