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 A32EFC4332F for ; Tue, 18 Oct 2022 08:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbiJRIg4 (ORCPT ); Tue, 18 Oct 2022 04:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiJRIgy (ORCPT ); Tue, 18 Oct 2022 04:36:54 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F8952DDB for ; Tue, 18 Oct 2022 01:36:53 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 29I8ZX7A019933-29I8ZX7D019933 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Oct 2022 16:35:54 +0800 From: Dongliang Mu To: Dave Kleikamp , Dongliang Mu , Zixuan Fu , Pavel Skripkin Cc: kernel test robot , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] fs: jfs: use the correct value to do sanity check Date: Tue, 18 Oct 2022 16:33:43 +0800 Message-Id: <20221018083346.855584-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The previous commit 920f4b7e923b ("fs: jfs: fix shift-out-of-bounds in dbAllocAG") incorrectly uses MAXMAPSIZE - L2MAXAG as upper bound to limit bmp->db_agl2size. The right value should be L2MAXL2SIZE - L2MAXAG, i.e., 13 + 10*3 - 7 = 36, according to Dave Kleikamp. Fix this by modifying the upper bound to the correct value. Reported-by: kernel test robot Fixes: 920f4b7e923b ("fs: jfs: fix shift-out-of-bounds in dbAllocAG") Signed-off-by: Dongliang Mu --- fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 962c855631cb..e1cbfbb60303 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -193,7 +193,7 @@ int dbMount(struct inode *ipbmap) bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth); bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart); bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size); - if (bmp->db_agl2size > MAXMAPSIZE - L2MAXAG) { + if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG) { err = -EINVAL; goto err_release_metapage; } -- 2.35.1