From patchwork Thu Nov 3 03:01:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 14593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp269139wru; Wed, 2 Nov 2022 19:19:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5zKtrwKDDg0qmrYQD7FKEEv/dPgRmdkij1i59dosOqHfrxLeNQ7oODywOyPgDrTFNqR/7K X-Received: by 2002:a17:902:c410:b0:187:190f:6aa2 with SMTP id k16-20020a170902c41000b00187190f6aa2mr21443908plk.88.1667441988110; Wed, 02 Nov 2022 19:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667441988; cv=none; d=google.com; s=arc-20160816; b=IB6/BFV+lVB06nIMJQ+209HyQYAdMEvnAcbALd8L8MqLsRVWr6CREhWdGftRLPz0Pu xyc+vHNAL6l7IsL582HCHm4Gh81lcEOi4DLCje9cLK7yCaeXd9RH8UWpye67kWzUt6ss Zpt3yFvjaXFpqVE2y0gRCYntSAej3ONTO6+Kinggp0xaufvKENoqFD589CMK2yi6muCF Hn4kfERlA6LDhCpuVngD7Bh2RDCZo4zQKplDmhuXwGhjomGiCtSmYN4xSx7F7hTTduXM oW5W42E4hAJktKBwzvwLRwZJAydpp0/t0o3IibxMLlWx1X4FYvuBeodhRtYHF76VQN0w tCAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oV/G8g4bwwUUih50GVI3HtLua+8uxwZ0gSnzKd7t1FM=; b=HIeerlMYBSqvqaox0A4M5BM2bB7wp0dr1F72KBXeUO8IQ1hHb9bCEFu2g6qteFt9Ay vD9VHiFcSBfTJyA3YoatJx71AX4MUoeKpGEjAX2fM3frn+LvYjw5DAyY4/svlsH7tzp7 UymQCVJmWeH/2Mf6d505T5p4rMu/MBVPngsZx+82pP6zKWcQ78Qi66Lw1zcwkkNtsIL3 DChXUBXcXSFzhXQ/g1uDjrAWqR/7bUUW2oLqvMddsowk3cDX2Gix0dM7hiPjshP7g5Z6 1VeB1ooWiyaZou8xCJVMgKBixu687fl69lJcENMkO1UuYkwBQza7IHdEcVUArHXtSKis gTSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a170903301300b00177568a0e53si15957813pla.252.2022.11.02.19.19.35; Wed, 02 Nov 2022 19:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbiKCCNz (ORCPT + 99 others); Wed, 2 Nov 2022 22:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbiKCCNv (ORCPT ); Wed, 2 Nov 2022 22:13:51 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C35B013D1B for ; Wed, 2 Nov 2022 19:13:50 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N2nNn6D9WzHvP4; Thu, 3 Nov 2022 10:13:29 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 10:13:49 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 10:13:48 +0800 From: Liu Shixin To: Dave Kleikamp CC: , , Liu Shixin Subject: [PATCH] fs/jfs: fix shift exponent db_agl2size negative Date: Thu, 3 Nov 2022 11:01:59 +0800 Message-ID: <20221103030159.163011-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748439650232890280?= X-GMAIL-MSGID: =?utf-8?q?1748439650232890280?= As a shift exponent, db_agl2size can not be less than 0. Add the missing check to fix the shift-out-of-bounds bug reported by syzkaller: UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:2227:15 shift exponent -744642816 is negative Reported-by: syzbot+0be96567042453c0c820@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Liu Shixin --- fs/jfs/jfs_dmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 765838578a72..a3eb1e826947 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -193,7 +193,8 @@ 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 > L2MAXL2SIZE - L2MAXAG) { + if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG || + bmp->db_agl2size < 0) { err = -EINVAL; goto err_release_metapage; }