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 1BDC91863 for ; Wed, 28 Dec 2022 15:49:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 929ECC433F0; Wed, 28 Dec 2022 15:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672242594; bh=0W0SzhsVRcakjw8atSqK/xCguPb5Za2BVR5rpbpA6XE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TOtXuGA1qpHfoJUYGRvP7qPmNPuSq7EJb/frTL/r5ULqaUUvW5zX/kjJBWQ3f03Ta xVeDgutEmJCDcxKHxGnvCTHai1BXiIt32QhQwQqEyF1QqmZmryjpYaHrCD5oTYT5UN fdCDNYNrBnfqHam+gba3xbpIQ0xB08gV4a/3fIXg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hoi Pok Wu , Dave Kleikamp , Sasha Levin Subject: [PATCH 5.15 623/731] fs: jfs: fix shift-out-of-bounds in dbDiscardAG Date: Wed, 28 Dec 2022 15:42:10 +0100 Message-Id: <20221228144314.592152016@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144256.536395940@linuxfoundation.org> References: <20221228144256.536395940@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Hoi Pok Wu [ Upstream commit 25e70c6162f207828dd405b432d8f2a98dbf7082 ] This should be applied to most URSAN bugs found recently by syzbot, by guarding the dbMount. As syzbot feeding rubbish into the bmap descriptor. Signed-off-by: Hoi Pok Wu Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/jfs_dmap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 44600cd7614a..f401bc05d5ff 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -198,6 +198,11 @@ int dbMount(struct inode *ipbmap) goto err_release_metapage; } + if (((bmp->db_mapsize - 1) >> bmp->db_agl2size) > MAXAG) { + err = -EINVAL; + goto err_release_metapage; + } + for (i = 0; i < MAXAG; i++) bmp->db_agfree[i] = le64_to_cpu(dbmp_le->dn_agfree[i]); bmp->db_agsize = le64_to_cpu(dbmp_le->dn_agsize); -- 2.35.1