Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3689846yba; Mon, 29 Apr 2019 07:00:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqywnRgdq96K2Z0r0iRRuUlgCc6tUmSh5/WLc3FN/AZw5bpHyIhcGPtXTFdTkDQCL4xDRNvp X-Received: by 2002:a65:654c:: with SMTP id a12mr27642239pgw.101.1556546433535; Mon, 29 Apr 2019 07:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556546433; cv=none; d=google.com; s=arc-20160816; b=R1CVIl2PYZ7m334ZTAMB9B6k2QuPxsrVXwJbtCDPrwuElO2379QyCFJT0xhZ/jmlBX j7BHnieIdRF8i1O3xjkkDpa+n3BJZvLoCBLiUbHBkINQleEIW62PsBm//v67vTYsszr0 RKWNRD08qgpRHBOTMMNhlnUTVFgU6bba+wucgKOEaDJQ7fWURnfmmd27GizF9rb2N8uf 2YQzRgaQzhCi0aawe82HKIeQ2gb4w4CVvO7d8vFTT/Aln0YVevI+nc8QlhRpRtcXqV9V U6yz3KYULq/BwAzJS64Jui1iExNkbiigDOLtOa5bnJL0LrXqeOM5qfD6pYwqNA46RKet GR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0q3Z65mUkX9MiUPRBj9xz436qcuv6TruvcgmXi2eCPI=; b=LE55dkfvReOwwYDcKG5lO7VYrcFxmpu4UvCLrGgu2DQapvw1+sYvHm6DxRhZUdYN3D rSA1oW9VURcdLqu6wNv9HpAWu8yPQgHUhWn9v5peDGEzT4d5zdL2T442Aclk03XP5Gsc v9KsTb93qMxWeJrCqhztikQq7mlEb7qj9hg9EFSKB4+AaSVYbP7V7BLAAR24VX11jn+S XUU/dc04Nyzr1elsUd8dBkrojcaRE+Xoku9Wx3E2ImlajTFBKB0PU/fXZc8+o9ijbAoU ZY1BOXcb2LjLqQr0jhWkuO16ZegGvzQ708l7kuln+PGSp6PJy358auxkQhHHsMYOKtVa hEcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DdkFCSpi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si15884644pff.1.2019.04.29.07.00.16; Mon, 29 Apr 2019 07:00:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DdkFCSpi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728227AbfD2N6G (ORCPT + 99 others); Mon, 29 Apr 2019 09:58:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:51980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727710AbfD2N6G (ORCPT ); Mon, 29 Apr 2019 09:58:06 -0400 Received: from [192.168.0.101] (unknown [58.212.133.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E38320652; Mon, 29 Apr 2019 13:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556546285; bh=zzwvCRjip66ErSWdogjE1z3JyHQPKCTMH76hG95wY1w=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DdkFCSpiMwzmY3iDUsGsYTswDof5oOHqj60kasboHy0kE0VndEZimiGBYSfWU204S 9e5fv4bm6bzhFRrmIte5RaP39uJp9Ftbt7Xoa2yr6HHy+SSDfss8MRa74r9KBYVlck I2rqUVIFc6M0eZt8uIooocVHfOP9EajhbVgSOikQ= Subject: Re: [PATCH] f2fs: fix to do sanity with enabled features in image To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20190424094850.118323-1-yuchao0@huawei.com> <20190428133802.GB37346@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: <373f4633-d331-5cf3-74b7-e982072bc4b4@kernel.org> Date: Mon, 29 Apr 2019 21:57:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190428133802.GB37346@jaegeuk-macbookpro.roam.corp.google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-4-28 21:38, Jaegeuk Kim wrote: > On 04/24, Chao Yu wrote: >> This patch fixes to do sanity with enabled features in image, if >> there are features kernel can not recognize, just fail the mount. > > We need to figure out per-feature-based rejection, since some of them can > be set without layout change. So any suggestion on how to implement this? Maybe: if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) check 4.14+ features else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) check 4.9+ features else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)) check 4.4+ features Thanks, > >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/f2fs.h | 13 +++++++++++++ >> fs/f2fs/super.c | 9 +++++++++ >> 2 files changed, 22 insertions(+) >> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >> index f5ffc09705eb..15b640967e12 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -151,6 +151,19 @@ struct f2fs_mount_info { >> #define F2FS_FEATURE_VERITY 0x0400 /* reserved */ >> #define F2FS_FEATURE_SB_CHKSUM 0x0800 >> >> +#define F2FS_ALL_FEATURES (F2FS_FEATURE_ENCRYPT | \ >> + F2FS_FEATURE_BLKZONED | \ >> + F2FS_FEATURE_ATOMIC_WRITE | \ >> + F2FS_FEATURE_EXTRA_ATTR | \ >> + F2FS_FEATURE_PRJQUOTA | \ >> + F2FS_FEATURE_INODE_CHKSUM | \ >> + F2FS_FEATURE_FLEXIBLE_INLINE_XATTR | \ >> + F2FS_FEATURE_QUOTA_INO | \ >> + F2FS_FEATURE_INODE_CRTIME | \ >> + F2FS_FEATURE_LOST_FOUND | \ >> + F2FS_FEATURE_VERITY | \ >> + F2FS_FEATURE_SB_CHKSUM) >> + >> #define __F2FS_HAS_FEATURE(raw_super, mask) \ >> ((raw_super->feature & cpu_to_le32(mask)) != 0) >> #define F2FS_HAS_FEATURE(sbi, mask) __F2FS_HAS_FEATURE(sbi->raw_super, mask) >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c >> index 4f8e9ab48b26..57f2fc6d14ba 100644 >> --- a/fs/f2fs/super.c >> +++ b/fs/f2fs/super.c >> @@ -2573,6 +2573,15 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, >> return 1; >> } >> >> + /* check whether kernel supports all features */ >> + if (le32_to_cpu(raw_super->feature) & (~F2FS_ALL_FEATURES)) { >> + f2fs_msg(sb, KERN_INFO, >> + "Unsupported feature:%u: supported:%u", >> + le32_to_cpu(raw_super->feature), >> + F2FS_ALL_FEATURES); >> + return 1; >> + } >> + >> /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */ >> if (sanity_check_area_boundary(sbi, bh)) >> return 1; >> -- >> 2.18.0.rc1