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 EF8981F790F; Tue, 26 Aug 2025 14:19:22 +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=1756217963; cv=none; b=UccJeJdx44sb3AP6jTdmolGJfVz7oiOVOgoVqDqOlfNGXFan7vaEl3hedzgm9LG7WbTNkPvUl8OtXCrHbUapFh7zzrHdvrOgcMAIoZu967bX6iTHrjyiY2Z5ZaugGvFrwqRw+hZZzY5DktLLkVRfdtrkTujVA2LwTz9xwSjyC3o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756217963; c=relaxed/simple; bh=hkCJWuDow/y0+mVn9r4TIexTPeU+6OFZmPBFXntYUCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zt0KBDrrvIpkOomGvvdhKST3husE21lmfzRTTMs/+oPMi9OMDusFwCiu4PyHvEzKCVwwW54ZAUMwjUsHo2WqxPFBFkpIQd9TccPy0p0tzoRvNgVMpJgROeqbNiylqEBjpFpd3bDf1R9x8s7bqxPY5ty2guF8O38BXZqvhMRQ1CE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GoNNLJ9t; 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="GoNNLJ9t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82485C113CF; Tue, 26 Aug 2025 14:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756217962; bh=hkCJWuDow/y0+mVn9r4TIexTPeU+6OFZmPBFXntYUCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoNNLJ9tsrSwnTBHU3Uc+b35vmi/mGqwEtcwG8kpiM7+iLlj4Aoj+cN1zkiMTW+xs FNE7RYPskHKEMbKkF7nc8T8vjed1WmPr97x1bnJn11RXtIqxPN/xM3GYHzlU/CyD3/ QHBjqQPWcaE+0l/X7y9ncova5c3KVBi2/xVkD/W8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+cffd18309153948f3c3e@syzkaller.appspotmail.com, Arnaud Lecomte , Dave Kleikamp , Sasha Levin Subject: [PATCH 5.10 300/523] jfs: upper bound check of tree index in dbAllocAG Date: Tue, 26 Aug 2025 13:08:30 +0200 Message-ID: <20250826110931.852600229@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110924.562212281@linuxfoundation.org> References: <20250826110924.562212281@linuxfoundation.org> User-Agent: quilt/0.68 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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnaud Lecomte [ Upstream commit c214006856ff52a8ff17ed8da52d50601d54f9ce ] When computing the tree index in dbAllocAG, we never check if we are out of bounds realative to the size of the stree. This could happen in a scenario where the filesystem metadata are corrupted. Reported-by: syzbot+cffd18309153948f3c3e@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=cffd18309153948f3c3e Tested-by: syzbot+cffd18309153948f3c3e@syzkaller.appspotmail.com Signed-off-by: Arnaud Lecomte Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/jfs_dmap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 234b7cc4acfa..f34025cc9b05 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -1457,6 +1457,12 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) (1 << (L2LPERCTL - (bmp->db_agheight << 1))) / bmp->db_agwidth; ti = bmp->db_agstart + bmp->db_agwidth * (agno & (agperlev - 1)); + if (ti < 0 || ti >= le32_to_cpu(dcp->nleafs)) { + jfs_error(bmp->db_ipbmap->i_sb, "Corrupt dmapctl page\n"); + release_metapage(mp); + return -EIO; + } + /* dmap control page trees fan-out by 4 and a single allocation * group may be described by 1 or 2 subtrees within the ag level * dmap control page, depending upon the ag size. examine the ag's -- 2.39.5