From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D243C677F1 for ; Mon, 16 Jan 2023 16:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232940AbjAPQhI (ORCPT ); Mon, 16 Jan 2023 11:37:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbjAPQge (ORCPT ); Mon, 16 Jan 2023 11:36:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E807026850 for ; Mon, 16 Jan 2023 08:25:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84D536104E 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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