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 201C746B5 for ; Mon, 16 Jan 2023 16:25:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98488C433F1; Mon, 16 Jan 2023 16:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673886330; bh=6TcQBBX1CzeR/LzibstlHVzvK58/kuduSl11CldcE7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qb8LpYTqJCDt0S0dPOb4LBLrVJqO1msSI737f+aqD3qdIAfbH2hdAOSqyOKedzF1h dzeHHkObZkvU70CQiPaFiMwSh5P00fNb8ILutpQI/8gPAhQfTPX7SNTNh9WAKX5dG7 nS3wZogPINFNaNpt84FaA6Ybu0Y2ROXH7FfYuYqM= 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.4 390/658] fs: jfs: fix shift-out-of-bounds in dbDiscardAG Date: Mon, 16 Jan 2023 16:47:58 +0100 Message-Id: <20230116154927.412710463@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154909.645460653@linuxfoundation.org> References: <20230116154909.645460653@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 3bcf98d01733..aa4643854f94 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