From patchwork Wed May 17 03:41:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 95029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp856231vqo; Tue, 16 May 2023 20:47:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZzEXTmxl2Jn0/I9uKZ3I6GPyNXZNzQLDJluMYcXqwJdAHUQEhyS2L9vyu0mzApYLmWQCt X-Received: by 2002:a05:6a00:10d4:b0:63c:1be4:5086 with SMTP id d20-20020a056a0010d400b0063c1be45086mr49344321pfu.6.1684295227724; Tue, 16 May 2023 20:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684295227; cv=none; d=google.com; s=arc-20160816; b=qgbQSDohQStapzKD+RXgMy4/VK84JNyq/v63TQtcFGYbXw6TqIKRzWKg62bTP9KPdp qXx/sSsCGQrt6/KyCUEAE1khP/jdm57qa7jLw0B2P2n1ECeQeUn8V98Qs4/pSW+CEM25 kfJUcCQlawiQSoWXJCxC1ydEtGVRVG5xh7JSiVl2Mz2CDpB3LLrg3+smAuGndrM8l7pV +v/T+uZpOIH8W8KVK5DtVM1rjoi+Zh7QpEntZD8747ZtOKcUFWgPMyVPwHaVRDJfQ7Yy rWwwakLGVkjYcD2qBWstoZ92+1LS/X1Zjk9tlB9kMET09lf5/xyAd9rNrGYifKnNBAqq In5g== 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:dkim-signature; bh=d3pTrwNPpmD+e+qlfroxQOmecTBXw8pq/ZMJFyNwMcc=; b=mjQpYxSeVBpjl314mZ9mrkq1XI8aGD00ZAafpKOy6evuxx1bhCqI4Rlo5D4FRw6aRh 6krZarV38ZYATV0Mb0yfbdOvEUmMKBMq/zb58Ym978MdRxmzpY2qpBQ2OTAHU9KhDPYX aDCMQRofWGx1VdCOrDLxMc9YrygG6DiV+wFsZtuFFftHmYgccIEH/3Xl3KDo4rhYBNp2 qMD4UP7L1Hoo0EM5vLdtscU08xvKVeMySCFaQu+flnyB8i/ftMoT04QhiG6kutaB8Otw LA5yI1X6rYoogQ06aCnnZYOZL26pnguVkpUmlmsMjLtqEnO2ga2HTU7DhCu+ed1A2QKG CLpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VqrUbrMh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020aa79845000000b0064391b0ea2csi20793125pfq.403.2023.05.16.20.46.53; Tue, 16 May 2023 20:47:07 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VqrUbrMh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232227AbjEQDlv (ORCPT + 99 others); Tue, 16 May 2023 23:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjEQDls (ORCPT ); Tue, 16 May 2023 23:41:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF14D171E for ; Tue, 16 May 2023 20:41:47 -0700 (PDT) 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 31FC3636E2 for ; Wed, 17 May 2023 03:41:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D064CC433EF; Wed, 17 May 2023 03:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684294906; bh=jIMBSZU6DcIg128BmiUzKyo1mKFJN6bwGmXxDRJS/7c=; h=From:To:Cc:Subject:Date:From; b=VqrUbrMhVu67DZAKgx7QGu0lljDrcRx6jtZsupnKWYnfdTmBgee5hTRyvBHETW+xo gXQE7ukGIpqQMSkqqK2I6imfGLm6KhutUU1M8JgTHVymX65P7ebFizM1SE5cCDgLz2 2ifO5Ze/6NuxTUI2dKlyEVqxEsHU0d6N0Lgc0w1IWuLIado07S9ucjmC7kTugM7W6A Dpz6KlMSaM4yMNxZU0YI4GvdildW/n3SoOWINSyUYW+t+vN/GRKPsPUno5NDG1186H Wxv7dex7f5zc8h579D3FnHFBRW7XY39PsHuw5IW03AKXj8YMH+dL/zduLpnCzKDLOn aBODLwSM8MNHw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2] f2fs: compress: fix to check validity of i_compress_flag field Date: Wed, 17 May 2023 11:41:39 +0800 Message-Id: <20230517034139.12879-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1766111552405974819?= X-GMAIL-MSGID: =?utf-8?q?1766111552405974819?= The last valid compress related field is i_compress_flag, check its validity instead of i_log_cluster_size. Signed-off-by: Chao Yu --- v2: - rebase the code. fs/f2fs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index f8bf75c1eca9..0a1748444329 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -361,7 +361,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) && fi->i_flags & F2FS_COMPR_FL && F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, - i_log_cluster_size)) + i_compress_flag)) return sanity_check_compress_inode(inode, ri); return true; @@ -490,7 +490,7 @@ static int do_read_inode(struct inode *inode) if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) && (fi->i_flags & F2FS_COMPR_FL)) { if (F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, - i_log_cluster_size)) { + i_compress_flag)) { unsigned short compress_flag; atomic_set(&fi->i_compr_blocks, @@ -728,7 +728,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) if (f2fs_sb_has_compression(F2FS_I_SB(inode)) && F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, - i_log_cluster_size)) { + i_compress_flag)) { unsigned short compress_flag; ri->i_compr_blocks =