From patchwork Thu Apr 21 05:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821107 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 41D7AC433FE for ; Thu, 21 Apr 2022 05:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378720AbiDUF01 (ORCPT ); Thu, 21 Apr 2022 01:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0Z (ORCPT ); Thu, 21 Apr 2022 01:26:25 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7053EDFAB; Wed, 20 Apr 2022 22:23:37 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id r83so3741221pgr.2; Wed, 20 Apr 2022 22:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6TLmqQdfX4YkZzTLAR0rl7KghqQxWM9b+06k+s5s34E=; b=KgB0v4CyaZksf924eGUftWqDhu3QSb+51gwgaAmkENKuVy4kX4gevOjinZmqPsAt2b 7fee0go6Eih8NF7lBpDgm2lG5zWcEDvjZoJ1M9x3mWVeypJM0EV0ESMU7MmeI8po1fsR vk0683XdRkQ+mY1SzWIpa8K+/UBrTsQzO/4smYGYJ0Zr1bEw8MNqF+CfwtfEykCkYS95 Iyr21DNJm8IwZtknLm0M4TLceXs0Smb3xnuYot1T7kzT0DBvmTwhFpl5qD9ySnb6Si62 NmuBgHZ0KGOqQuwXwcFC1s6EJGjqXJ4SxDZ2mRMcFFWxUZJ/WAxY0PhTZmTKv/HFbxfR UYww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6TLmqQdfX4YkZzTLAR0rl7KghqQxWM9b+06k+s5s34E=; b=ioxZt7UqIIjmfwZPKZWwzGQ4gG3rll9jjnb3OZFil/MqIFTT/1A28YUzXwkzku+ROg yufH0SqOJKuDw4TW3C3AdC5MveVHRFomGWYhtuZXwpgNn7b7njwzgIYmejmH22gEO4Tm fmAMJRBKH58NxzcD5Lm2gGwNp1m/PeHoUPxYRYMi9siY5JVWgCoEM7ULp3F39E8kfR05 VIlqa0Q0g1PBY8/k6CAUyWqfEKV+1/HzAc4CcsztgRyYUH4FBES86ooLVLeoWvCTOfQW JNaoZgY3Nw3Ba+6K0NnUF9L8g8pByvvXy1m2RACZHqNw1zaG6eUs5+ZO1tbiWeNEh0nq UeEA== X-Gm-Message-State: AOAM533wOkl4kWlpepS/Zh4Sk9hlZJ567stTkHXrVVjrhG+Kr+JA18T5 gIgLorFMSmI2VpGrzRLZFZa7vkdcKY8= X-Google-Smtp-Source: ABdhPJyloJo/16EbPc21doM3ov6i/2iOsRHAIMkz8uE4CciBV6O0+f4dfRV29osVWMX+UUb0OW/x8g== X-Received: by 2002:a63:f047:0:b0:399:24bb:7fa1 with SMTP id s7-20020a63f047000000b0039924bb7fa1mr21948501pgj.397.1650518616846; Wed, 20 Apr 2022 22:23:36 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id u10-20020a17090a890a00b001cb14240c4csm1119494pjn.1.2022.04.20.22.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:23:36 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 1/6] fscrypt: Provide definition of fscrypt_set_test_dummy_encryption Date: Thu, 21 Apr 2022 10:53:17 +0530 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org Provide definition of fscrypt_set_test_dummy_encryption() when CONFIG_FS_ENCRYPTION is disabled. This then returns -EOPNOTSUPP. Signed-off-by: Ritesh Harjani --- include/linux/fscrypt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 91ea9477e9bd..18dd6048bab3 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -467,6 +467,13 @@ static inline int fscrypt_set_context(struct inode *inode, void *fs_data) struct fscrypt_dummy_policy { }; +static inline int fscrypt_set_test_dummy_encryption(struct super_block *sb, + const char *arg, + struct fscrypt_dummy_policy *dummy_policy) +{ + return -EOPNOTSUPP; +} + static inline void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep, struct super_block *sb) From patchwork Thu Apr 21 05:23:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821108 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 A6C41C433EF for ; Thu, 21 Apr 2022 05:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381649AbiDUF0b (ORCPT ); Thu, 21 Apr 2022 01:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0b (ORCPT ); Thu, 21 Apr 2022 01:26:31 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E567DFAB; Wed, 20 Apr 2022 22:23:42 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id z16so3975440pfh.3; Wed, 20 Apr 2022 22:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ukkzC5rglV7fdpwJa+4gSQZ0vM4mRRWo6ddpHTdRkc0=; b=RN8RtVLcLlPGScmT/nyoxbzYpl76nbzCWM1Wz3Y8QzQHXYEVF1chq75mVodyGttCNX ML/L5XSboU+7+9q/lveSqX+bbsRikHkdqvnlVd8NBVPmoKaqje1KSruz5VLfkREd38kq cPHyfIxEDSQ0hM9EDKZQufCqVRMdeiaqTmlITOFVgAWXZaQVdrtsFjV0qOIP4KQzlV9n 8MYA/iNhKvV1LzsMAcbfyUBEtmN2lYFXtqmvFx1+xFtebdfkmk3E80psRKcY0UfHMoya TU9DLXTDqoPLERl+wfrZYRyihjcWmlR7XPoDrNmCi1Vczxw0GnbLjWQip+dthUMx80r3 I/RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ukkzC5rglV7fdpwJa+4gSQZ0vM4mRRWo6ddpHTdRkc0=; b=dftghBQ42/yjw/mQuZiUBldTByLIsoFC4/gQSiY9QaBn1MDWTr7ZZcRsqvzZbsj0/z Crq4EQLseVw/uj+N7JaavyFFKvWZTfz0j7zpGaRcLS0HDPHze4Mrw7ZkkElvZtTeJ00D zZB+BVySgQ/hgjAVAmvSZ+VtJPKBx7lqg8FblapaSYCtXtc4Zx3VUaFVPcI1Nsfg4PHc UyYtfs5Mrx51CB67tAsvBFfu932A5UB0lMpjfxGTAwvNELyDeQ84nhShJFJe+R2a6+YA UZHpLpEd91+th1qkmpdKkm9MB0pwXqLZOZqOH9w5HJAFixhTKVREv8B64g+rOGaxdzjA tW1g== X-Gm-Message-State: AOAM532bxM9DRvkQZ9ibfl3MdkqLGnEfAHFB/oNualgm5sEt1WDo3SKr 4JF5KwAFxV2K6lT9WiAM883xWYLpGCs= X-Google-Smtp-Source: ABdhPJwnDwxPR0lWKfmyrjf/V/ZExjpsu6V0tmvNcU7H2pagf5LXLGkloXnDX6aOmwA68vv2CJ9pFQ== X-Received: by 2002:a05:6a00:3497:b0:50a:d54c:7de1 with SMTP id cp23-20020a056a00349700b0050ad54c7de1mr2716707pfb.52.1650518621676; Wed, 20 Apr 2022 22:23:41 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id w7-20020aa79547000000b0050ad0e82e6dsm2465805pfq.215.2022.04.20.22.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:23:41 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 2/6] ext4: Move ext4 crypto code to its own file ext4_crypto.c Date: Thu, 21 Apr 2022 10:53:18 +0530 Message-Id: <165505b3603b7e957acfa9a90f38455d5da530ae.1650517532.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org This is to cleanup super.c file which has grown quite large. So, start moving ext4 crypto related code to where it should be in the first place i.e. fs/ext4/ext4_crypto.c Signed-off-by: Ritesh Harjani --- fs/ext4/Makefile | 1 + fs/ext4/ext4.h | 3 + fs/ext4/ext4_crypto.c | 127 ++++++++++++++++++++++++++++++++++++++++++ fs/ext4/super.c | 122 ---------------------------------------- 4 files changed, 131 insertions(+), 122 deletions(-) create mode 100644 fs/ext4/ext4_crypto.c diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile index 7d89142e1421..b340fe5f849c 100644 --- a/fs/ext4/Makefile +++ b/fs/ext4/Makefile @@ -17,3 +17,4 @@ ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o ext4-inode-test-objs += inode-test.o obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-inode-test.o ext4-$(CONFIG_FS_VERITY) += verity.o +ext4-$(CONFIG_FS_ENCRYPTION) += ext4_crypto.o diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 1d79012c5a5b..8bac8af25ed8 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2727,6 +2727,9 @@ extern int ext4_fname_setup_ci_filename(struct inode *dir, struct ext4_filename *fname); #endif +/* ext4 encryption related stuff goes here ext4_crypto.c */ +extern const struct fscrypt_operations ext4_cryptops; + #ifdef CONFIG_FS_ENCRYPTION static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst, const struct fscrypt_name *src) diff --git a/fs/ext4/ext4_crypto.c b/fs/ext4/ext4_crypto.c new file mode 100644 index 000000000000..e5413c0970ee --- /dev/null +++ b/fs/ext4/ext4_crypto.c @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +#include "ext4.h" +#include "xattr.h" +#include "ext4_jbd2.h" + +static int ext4_get_context(struct inode *inode, void *ctx, size_t len) +{ + return ext4_xattr_get(inode, EXT4_XATTR_INDEX_ENCRYPTION, + EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len); +} + +static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, + void *fs_data) +{ + handle_t *handle = fs_data; + int res, res2, credits, retries = 0; + + /* + * Encrypting the root directory is not allowed because e2fsck expects + * lost+found to exist and be unencrypted, and encrypting the root + * directory would imply encrypting the lost+found directory as well as + * the filename "lost+found" itself. + */ + if (inode->i_ino == EXT4_ROOT_INO) + return -EPERM; + + if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + return -EINVAL; + + if (ext4_test_inode_flag(inode, EXT4_INODE_DAX)) + return -EOPNOTSUPP; + + res = ext4_convert_inline_data(inode); + if (res) + return res; + + /* + * If a journal handle was specified, then the encryption context is + * being set on a new inode via inheritance and is part of a larger + * transaction to create the inode. Otherwise the encryption context is + * being set on an existing inode in its own transaction. Only in the + * latter case should the "retry on ENOSPC" logic be used. + */ + + if (handle) { + res = ext4_xattr_set_handle(handle, inode, + EXT4_XATTR_INDEX_ENCRYPTION, + EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, + ctx, len, 0); + if (!res) { + ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); + ext4_clear_inode_state(inode, + EXT4_STATE_MAY_INLINE_DATA); + /* + * Update inode->i_flags - S_ENCRYPTED will be enabled, + * S_DAX may be disabled + */ + ext4_set_inode_flags(inode, false); + } + return res; + } + + res = dquot_initialize(inode); + if (res) + return res; +retry: + res = ext4_xattr_set_credits(inode, len, false /* is_create */, + &credits); + if (res) + return res; + + handle = ext4_journal_start(inode, EXT4_HT_MISC, credits); + if (IS_ERR(handle)) + return PTR_ERR(handle); + + res = ext4_xattr_set_handle(handle, inode, EXT4_XATTR_INDEX_ENCRYPTION, + EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, + ctx, len, 0); + if (!res) { + ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); + /* + * Update inode->i_flags - S_ENCRYPTED will be enabled, + * S_DAX may be disabled + */ + ext4_set_inode_flags(inode, false); + res = ext4_mark_inode_dirty(handle, inode); + if (res) + EXT4_ERROR_INODE(inode, "Failed to mark inode dirty"); + } + res2 = ext4_journal_stop(handle); + + if (res == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) + goto retry; + if (!res) + res = res2; + return res; +} + +static const union fscrypt_policy *ext4_get_dummy_policy(struct super_block *sb) +{ + return EXT4_SB(sb)->s_dummy_enc_policy.policy; +} + +static bool ext4_has_stable_inodes(struct super_block *sb) +{ + return ext4_has_feature_stable_inodes(sb); +} + +static void ext4_get_ino_and_lblk_bits(struct super_block *sb, + int *ino_bits_ret, int *lblk_bits_ret) +{ + *ino_bits_ret = 8 * sizeof(EXT4_SB(sb)->s_es->s_inodes_count); + *lblk_bits_ret = 8 * sizeof(ext4_lblk_t); +} + +const struct fscrypt_operations ext4_cryptops = { + .key_prefix = "ext4:", + .get_context = ext4_get_context, + .set_context = ext4_set_context, + .get_dummy_policy = ext4_get_dummy_policy, + .empty_dir = ext4_empty_dir, + .has_stable_inodes = ext4_has_stable_inodes, + .get_ino_and_lblk_bits = ext4_get_ino_and_lblk_bits, +}; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ae98b07285d2..8bb5fa15a013 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1488,128 +1488,6 @@ static int ext4_nfs_commit_metadata(struct inode *inode) return ext4_write_inode(inode, &wbc); } -#ifdef CONFIG_FS_ENCRYPTION -static int ext4_get_context(struct inode *inode, void *ctx, size_t len) -{ - return ext4_xattr_get(inode, EXT4_XATTR_INDEX_ENCRYPTION, - EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len); -} - -static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, - void *fs_data) -{ - handle_t *handle = fs_data; - int res, res2, credits, retries = 0; - - /* - * Encrypting the root directory is not allowed because e2fsck expects - * lost+found to exist and be unencrypted, and encrypting the root - * directory would imply encrypting the lost+found directory as well as - * the filename "lost+found" itself. - */ - if (inode->i_ino == EXT4_ROOT_INO) - return -EPERM; - - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) - return -EINVAL; - - if (ext4_test_inode_flag(inode, EXT4_INODE_DAX)) - return -EOPNOTSUPP; - - res = ext4_convert_inline_data(inode); - if (res) - return res; - - /* - * If a journal handle was specified, then the encryption context is - * being set on a new inode via inheritance and is part of a larger - * transaction to create the inode. Otherwise the encryption context is - * being set on an existing inode in its own transaction. Only in the - * latter case should the "retry on ENOSPC" logic be used. - */ - - if (handle) { - res = ext4_xattr_set_handle(handle, inode, - EXT4_XATTR_INDEX_ENCRYPTION, - EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, - ctx, len, 0); - if (!res) { - ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); - ext4_clear_inode_state(inode, - EXT4_STATE_MAY_INLINE_DATA); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ - ext4_set_inode_flags(inode, false); - } - return res; - } - - res = dquot_initialize(inode); - if (res) - return res; -retry: - res = ext4_xattr_set_credits(inode, len, false /* is_create */, - &credits); - if (res) - return res; - - handle = ext4_journal_start(inode, EXT4_HT_MISC, credits); - if (IS_ERR(handle)) - return PTR_ERR(handle); - - res = ext4_xattr_set_handle(handle, inode, EXT4_XATTR_INDEX_ENCRYPTION, - EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, - ctx, len, 0); - if (!res) { - ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); - /* - * Update inode->i_flags - S_ENCRYPTED will be enabled, - * S_DAX may be disabled - */ - ext4_set_inode_flags(inode, false); - res = ext4_mark_inode_dirty(handle, inode); - if (res) - EXT4_ERROR_INODE(inode, "Failed to mark inode dirty"); - } - res2 = ext4_journal_stop(handle); - - if (res == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) - goto retry; - if (!res) - res = res2; - return res; -} - -static const union fscrypt_policy *ext4_get_dummy_policy(struct super_block *sb) -{ - return EXT4_SB(sb)->s_dummy_enc_policy.policy; -} - -static bool ext4_has_stable_inodes(struct super_block *sb) -{ - return ext4_has_feature_stable_inodes(sb); -} - -static void ext4_get_ino_and_lblk_bits(struct super_block *sb, - int *ino_bits_ret, int *lblk_bits_ret) -{ - *ino_bits_ret = 8 * sizeof(EXT4_SB(sb)->s_es->s_inodes_count); - *lblk_bits_ret = 8 * sizeof(ext4_lblk_t); -} - -static const struct fscrypt_operations ext4_cryptops = { - .key_prefix = "ext4:", - .get_context = ext4_get_context, - .set_context = ext4_set_context, - .get_dummy_policy = ext4_get_dummy_policy, - .empty_dir = ext4_empty_dir, - .has_stable_inodes = ext4_has_stable_inodes, - .get_ino_and_lblk_bits = ext4_get_ino_and_lblk_bits, -}; -#endif - #ifdef CONFIG_QUOTA static const char * const quotatypes[] = INITQFNAMES; #define QTYPE2NAME(t) (quotatypes[t]) From patchwork Thu Apr 21 05:23:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821109 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 910FBC433F5 for ; Thu, 21 Apr 2022 05:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384297AbiDUF0f (ORCPT ); Thu, 21 Apr 2022 01:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0f (ORCPT ); Thu, 21 Apr 2022 01:26:35 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00FB3DFAB; Wed, 20 Apr 2022 22:23:46 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id ga4-20020a17090b038400b001d4b33c74ccso2904121pjb.1; Wed, 20 Apr 2022 22:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mkTk6jJ30N/x3F4AyIBMkhdrEysHqLwx5nd2q3CElLU=; b=Hc0+5IgrOya2iYRzrDxmtBBvxHXeMw89ZPAP7iTNdSp6LlrD6DHKIteDsapSIPn+Zz vv2qF1dTw4fLdGTkQtwGH70TmBB5kOdtIPbKrQ8khICLgKd7Rnpi8zqekpr0lcnnNp5H C9Hkw/X9CMDaO+BK163KMxwDk5A6PKZsTYnFG9T2Sgzmkzch7bBH9R3EEwCm6zEbcF8C S2VYWsPHfGriq+4302WB9Tgqo9Hp6gcjLUuzeggRYdcLotGNqCIT72DYwuVihl2rEMib KsVZ5vvp8CJvWOcpG1nG1MyUiaLWkQX0fYECcttcCA5VDj6ZktlWvbvjdP0hBuX1luqq uJww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mkTk6jJ30N/x3F4AyIBMkhdrEysHqLwx5nd2q3CElLU=; b=g8EM6YmhvpYRYPbb1l3Jb4uDExQvKseEQSaGB7E2Cra4EtrlA96cexJv8hWHaKgRVY UkD6FliIdsB3Qn333RzArgr/Z02hRSSGLwNzsvr0QkkQifvOMqo+s1yXmPLFIuQMhCqw 3LrR8//SnzW4g7noGQKDXxDpFiUYN/PZLiPWUVsyW5DRfpl0PzcanePlL7VoVSDXDKJy T0GQIBH70xeIeg9AvVnfLSYjMSQdNVYsuJ127syrbTlKMgSfZuxtlHxU4Ye7UkPupgrk rW9G+cgmqFOauoJWBqS43IsaVhCP4mwsOn2RUynuNDD+uLFyviQ9ZlEQXAbZn0xFr/YQ Xk/A== X-Gm-Message-State: AOAM533GbI4J47QysIl4vh97bC9VH5dpaGcETH9xuKXH7hejXI76pT8o DxyvB0nLGTJmTTqPPYp36xuBtOtTO9Q= X-Google-Smtp-Source: ABdhPJyw7NGf2k92oHzVhHWDLm02aKic69xkIBEFIN2vA+HRraI79QeKnIN4lTcF6ljYFGbczB77BA== X-Received: by 2002:a17:90a:2809:b0:1cb:99a8:ffcd with SMTP id e9-20020a17090a280900b001cb99a8ffcdmr8452065pjd.7.1650518626541; Wed, 20 Apr 2022 22:23:46 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id cu19-20020a17090afa9300b001cd4989ff59sm988919pjb.32.2022.04.20.22.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:23:46 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 3/6] ext4: Directly opencode ext4_set_test_dummy_encryption Date: Thu, 21 Apr 2022 10:53:19 +0530 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org Simplify the code by opencoding ext4_set_test_dummy_encryption(), since there is only one caller of it and ext4_** variant in itself does nothing special other than calling fscrypt_set_test_dummy_encryption(). This can be done directly by opencoding it in the caller. Signed-off-by: Ritesh Harjani --- fs/ext4/super.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8bb5fa15a013..e7e5c9c057d7 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1863,24 +1863,6 @@ ext4_sb_read_encoding(const struct ext4_super_block *es) } #endif -static int ext4_set_test_dummy_encryption(struct super_block *sb, char *arg) -{ -#ifdef CONFIG_FS_ENCRYPTION - struct ext4_sb_info *sbi = EXT4_SB(sb); - int err; - - err = fscrypt_set_test_dummy_encryption(sb, arg, - &sbi->s_dummy_enc_policy); - if (err) { - ext4_msg(sb, KERN_WARNING, - "Error while setting test dummy encryption [%d]", err); - return err; - } - ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); -#endif - return 0; -} - #define EXT4_SPEC_JQUOTA (1 << 0) #define EXT4_SPEC_JQFMT (1 << 1) #define EXT4_SPEC_DATAJ (1 << 2) @@ -2795,8 +2777,20 @@ static int ext4_apply_options(struct fs_context *fc, struct super_block *sb) ext4_apply_quota_options(fc, sb); - if (ctx->spec & EXT4_SPEC_DUMMY_ENCRYPTION) - ret = ext4_set_test_dummy_encryption(sb, ctx->test_dummy_enc_arg); + if (IS_ENABLED(CONFIG_FS_ENCRYPTION) && + (ctx->spec & EXT4_SPEC_DUMMY_ENCRYPTION)) { + + ret = fscrypt_set_test_dummy_encryption(sb, + ctx->test_dummy_enc_arg, + &sbi->s_dummy_enc_policy); + if (ret) { + ext4_msg(sb, KERN_WARNING, "Error while setting test dummy encryption [%d]", + ret); + return ret; + } + + ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); + } return ret; } From patchwork Thu Apr 21 05:23:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821110 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 A6BCDC433EF for ; Thu, 21 Apr 2022 05:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384304AbiDUF0k (ORCPT ); Thu, 21 Apr 2022 01:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0k (ORCPT ); Thu, 21 Apr 2022 01:26:40 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6F0DFB1; Wed, 20 Apr 2022 22:23:51 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id l127so3973641pfl.6; Wed, 20 Apr 2022 22:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nAKdB7OlNBPLSXEPrWPj54rwnqnTQlbZgYB1Swf5oy4=; b=fkYbjCMvDg0qkUwF8guksF3TwEPZnQCCyg+zk1xlXSgeArgoyfGnKnrKLPBs0qThB4 PolkXz0oOctKv/X/ci91Slc/6IT+N3IjoYoOm69wDvrw4lOmyzZ9EgEoKVnz1GDu+c5c 80TZHM6EVilHh7s/SX5B9ryEUVpRJ74FC6sBBO5oABST8iQTsmyzqjCv6VYrrb7IXByE cRMqcMlh8OVPdj2h4XfI82griaJfgzR/uoH/GlSl17BZ0Nac50F/xIeNtD8vsMHPPYyG xLSItzsmxjaW3G3TNSqtTdEb3qPlsW7NvVI/ovPauLyXaxx+KalgDgY0dwIKRD9tdEL8 znnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nAKdB7OlNBPLSXEPrWPj54rwnqnTQlbZgYB1Swf5oy4=; b=eR/6215F6R+KEK+iTJhuY2qJMJz0VYtHK58CEfTiP29/y2wXE7d/pC4lRqJS2kIlRQ TkeTzjAIVaIIau6WFOZgC6p2Z9tZXeOKxoBkzljQgibbvdM52IMYjU2vqVLDdQUVjrYx Xk+t4MDeWY9rgjuWWuaKOsy36TKcyScKSF0p2PG0KiDV0RkD4wR4L4JAHSDZs/GxYHKX +UOb40YeJJ5yvWqP/aAI6iMBc5P72n8WH60soeC7TQiLwmg69ZhR4R7yUlppD7+z3gTJ E+pNoKClmVxoiJ17zrLD2opw7z4P+Z2bqZfSaCjj2Wza/gcjFK8v5kzGuocBJNw6AlLb HW1A== X-Gm-Message-State: AOAM530J/Nsz8JPGU1QbArVRykItswIRvpqZgVDL99elStEEM8N9b1K5 KggepoH1wzZZ8DxLyBtUsdxF2pCkyo8= X-Google-Smtp-Source: ABdhPJx8/NhAAgdA1VPtYLg+J5vqrTzY9NcllaF/sbVbOO2uH0D/6Pm8IexY0znMLR7jFTrpMUmz3A== X-Received: by 2002:a63:3e0a:0:b0:3aa:646f:f445 with SMTP id l10-20020a633e0a000000b003aa646ff445mr6597605pga.30.1650518631381; Wed, 20 Apr 2022 22:23:51 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id w187-20020a6230c4000000b00505cde77826sm21554169pfw.159.2022.04.20.22.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:23:51 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 4/6] ext4: Cleanup function defs from ext4.h into ext4_crypto.c Date: Thu, 21 Apr 2022 10:53:20 +0530 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org Some of these functions when CONFIG_FS_ENCRYPTION is enabled are not really inline (let compiler be the best judge of it). Remove inline and move them into ext4_crypto.c where they should be present. Signed-off-by: Ritesh Harjani --- fs/ext4/ext4.h | 70 ++++--------------------------------------- fs/ext4/ext4_crypto.c | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 64 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 8bac8af25ed8..caf154db4680 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2731,73 +2731,15 @@ extern int ext4_fname_setup_ci_filename(struct inode *dir, extern const struct fscrypt_operations ext4_cryptops; #ifdef CONFIG_FS_ENCRYPTION -static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst, - const struct fscrypt_name *src) -{ - memset(dst, 0, sizeof(*dst)); - - dst->usr_fname = src->usr_fname; - dst->disk_name = src->disk_name; - dst->hinfo.hash = src->hash; - dst->hinfo.minor_hash = src->minor_hash; - dst->crypto_buf = src->crypto_buf; -} - -static inline int ext4_fname_setup_filename(struct inode *dir, - const struct qstr *iname, - int lookup, - struct ext4_filename *fname) -{ - struct fscrypt_name name; - int err; +int ext4_fname_setup_filename(struct inode *dir, + const struct qstr *iname, int lookup, + struct ext4_filename *fname); - err = fscrypt_setup_filename(dir, iname, lookup, &name); - if (err) - return err; +int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, + struct ext4_filename *fname); - ext4_fname_from_fscrypt_name(fname, &name); +void ext4_fname_free_filename(struct ext4_filename *fname); -#if IS_ENABLED(CONFIG_UNICODE) - err = ext4_fname_setup_ci_filename(dir, iname, fname); -#endif - return err; -} - -static inline int ext4_fname_prepare_lookup(struct inode *dir, - struct dentry *dentry, - struct ext4_filename *fname) -{ - struct fscrypt_name name; - int err; - - err = fscrypt_prepare_lookup(dir, dentry, &name); - if (err) - return err; - - ext4_fname_from_fscrypt_name(fname, &name); - -#if IS_ENABLED(CONFIG_UNICODE) - err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); -#endif - return err; -} - -static inline void ext4_fname_free_filename(struct ext4_filename *fname) -{ - struct fscrypt_name name; - - name.crypto_buf = fname->crypto_buf; - fscrypt_free_filename(&name); - - fname->crypto_buf.name = NULL; - fname->usr_fname = NULL; - fname->disk_name.name = NULL; - -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name = NULL; -#endif -} #else /* !CONFIG_FS_ENCRYPTION */ static inline int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, diff --git a/fs/ext4/ext4_crypto.c b/fs/ext4/ext4_crypto.c index e5413c0970ee..7e89f86a4429 100644 --- a/fs/ext4/ext4_crypto.c +++ b/fs/ext4/ext4_crypto.c @@ -6,6 +6,71 @@ #include "xattr.h" #include "ext4_jbd2.h" +void ext4_fname_from_fscrypt_name(struct ext4_filename *dst, + const struct fscrypt_name *src) +{ + memset(dst, 0, sizeof(*dst)); + + dst->usr_fname = src->usr_fname; + dst->disk_name = src->disk_name; + dst->hinfo.hash = src->hash; + dst->hinfo.minor_hash = src->minor_hash; + dst->crypto_buf = src->crypto_buf; +} + +int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, + int lookup, struct ext4_filename *fname) +{ + struct fscrypt_name name; + int err; + + err = fscrypt_setup_filename(dir, iname, lookup, &name); + if (err) + return err; + + ext4_fname_from_fscrypt_name(fname, &name); + +#if IS_ENABLED(CONFIG_UNICODE) + err = ext4_fname_setup_ci_filename(dir, iname, fname); +#endif + return err; +} + +int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, + struct ext4_filename *fname) +{ + struct fscrypt_name name; + int err; + + err = fscrypt_prepare_lookup(dir, dentry, &name); + if (err) + return err; + + ext4_fname_from_fscrypt_name(fname, &name); + +#if IS_ENABLED(CONFIG_UNICODE) + err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); +#endif + return err; +} + +void ext4_fname_free_filename(struct ext4_filename *fname) +{ + struct fscrypt_name name; + + name.crypto_buf = fname->crypto_buf; + fscrypt_free_filename(&name); + + fname->crypto_buf.name = NULL; + fname->usr_fname = NULL; + fname->disk_name.name = NULL; + +#if IS_ENABLED(CONFIG_UNICODE) + kfree(fname->cf_name.name); + fname->cf_name.name = NULL; +#endif +} + static int ext4_get_context(struct inode *inode, void *ctx, size_t len) { return ext4_xattr_get(inode, EXT4_XATTR_INDEX_ENCRYPTION, From patchwork Thu Apr 21 05:23:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821111 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 BC955C433F5 for ; Thu, 21 Apr 2022 05:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384307AbiDUF0p (ORCPT ); Thu, 21 Apr 2022 01:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0p (ORCPT ); Thu, 21 Apr 2022 01:26:45 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1434DFAF; Wed, 20 Apr 2022 22:23:56 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id iq10so192464pjb.0; Wed, 20 Apr 2022 22:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kqyIPRpEKHi3QFbh2k8vw2KJbGiX1tCP5QuWevqqO4c=; b=J0neBI/t2C848zvRKU4xgW7MW/VFnC1S1H5xglcX5U5iZRhV+I/sqt28r7Z8stJLDf JFOzBlyvXHzTPfwMyu0LcKwYgLLClLpwXBIYQiVY/TsymAtGAMeBWwQ330SPwAjc6onl 1BTpOXN4Phzr33WoJFjYuZG4sKqhBoieCBOhQeUeCiBKSC0FNGaCqwp+y40VCJnYBAGl YEJpGSEcxiA7YCvdJTlUI1aKQrYlgL2UnpKhK5NFYGSmHeVoptmIDW3ipUR8QxwtV/u+ d5BPE3Go5PCJ/HJbYuBOv/xCm4cghS9qmyEs7bRL7qEVlGlrHmTCpXyNmmhWAkoBPnrN hj5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kqyIPRpEKHi3QFbh2k8vw2KJbGiX1tCP5QuWevqqO4c=; b=scBFqn9+nfI22CxPe6O7S7DNZ8T3AUabiJaXgCKOttIKTgqkeAa8loONPjDoh9X+4H zT7KGOy6VbpRJkTPVmM3/gh0dmpr5dVcVWD8RDPZ6XWIwg8Ss5qWrR3TEQXhF+jH/2Ow rOWh4idvr5a+nQ2GANERGvuHGcAN54Na4oKKIRCflzkt5sp2NiARhoNVMtaN83RZRXhN xMH8mnXvMemR47HJR0nweP+7nqR9LXbshYXSC5YGPMwGHVu3FzQg6m5PLaHk4kW2LeD5 J1K0IioozQkvPB/pXEvvhKQHTqJVrmZExaVsfsbF8uzHeU99QBIMcF/BZa4w6CijBDkO VslA== X-Gm-Message-State: AOAM530rh4T2IlAJCl3OPnqgDMds5lI1enfOjD/JEuFMjGw4ZzoEiW2i kWBSrP7HBp5HhQdEVtE/Ir5xoPKwqHY= X-Google-Smtp-Source: ABdhPJw+yV11ELgKTtNfxUw/xsRDwao3556g5tiFbEVMrv43Lm9Fx9hzmkeHRrXJeo65ocMjoGiuPw== X-Received: by 2002:a17:90a:f00c:b0:1cb:8361:c78e with SMTP id bt12-20020a17090af00c00b001cb8361c78emr8457233pjb.133.1650518636156; Wed, 20 Apr 2022 22:23:56 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id s62-20020a635e41000000b003a9eb7f65absm4346225pgb.85.2022.04.20.22.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:23:55 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 5/6] ext4: Move all encryption related into a common #ifdef Date: Thu, 21 Apr 2022 10:53:21 +0530 Message-Id: <74855c5d50db92722213a738c0fb43a878dc6557.1650517532.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org This just moves left over usages of #ifdef CONFIG_FS_ENCRYPTION into a common place for function/macro definitions. Signed-off-by: Ritesh Harjani --- fs/ext4/ext4.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.31.1 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index caf154db4680..2fb69c500063 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1440,12 +1440,6 @@ struct ext4_super_block { #ifdef __KERNEL__ -#ifdef CONFIG_FS_ENCRYPTION -#define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL) -#else -#define DUMMY_ENCRYPTION_ENABLED(sbi) (0) -#endif - /* Number of quota types we support */ #define EXT4_MAXQUOTAS 3 @@ -2740,6 +2734,8 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, void ext4_fname_free_filename(struct ext4_filename *fname); +#define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL) + #else /* !CONFIG_FS_ENCRYPTION */ static inline int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname, @@ -2772,6 +2768,8 @@ static inline void ext4_fname_free_filename(struct ext4_filename *fname) fname->cf_name.name = NULL; #endif } + +#define DUMMY_ENCRYPTION_ENABLED(sbi) (0) #endif /* !CONFIG_FS_ENCRYPTION */ /* dir.c */ From patchwork Thu Apr 21 05:23:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 12821112 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 D1096C433F5 for ; Thu, 21 Apr 2022 05:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384317AbiDUF0v (ORCPT ); Thu, 21 Apr 2022 01:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233065AbiDUF0u (ORCPT ); Thu, 21 Apr 2022 01:26:50 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0728BDFAB; Wed, 20 Apr 2022 22:24:02 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id q19so3722396pgm.6; Wed, 20 Apr 2022 22:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ptNcYKMP2I9D0WN8B4M/VfkLKR53Y5iVYHD6TbxFc6U=; b=AMRwCG3nUp5EE4g2BNFxqtPdBy9Yg0bottvFQICBOguL5h9OvNn6Hj39qVPOjzcHMr 43aH11zzpdSMiS9BOWbI0NNG235rOxztPsiPLTL/cnzmNCKrf5TqAUYZXN+Y1WjBG9wH lAoXmibJysiWlt8pWXpKtQzmyyKrqPfHr1beWhOYOs/e5+SPg8T5fMyPSABpOxfrj80y E/3vAKgsN0Z3uS3a2U8EoFZy/uo9cbOieH4zHOWK7EHg53JEPmGWBe/PxjOaZlySKgxV 5vrIsNfln+R0SriuiUrjSNEIsPBF1NUZybp4XRBnAxytY0DdgQjqXGr+6mBxa4y0Qzjg vccw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ptNcYKMP2I9D0WN8B4M/VfkLKR53Y5iVYHD6TbxFc6U=; b=WZCdsgSHz6yDBp6tcbS4R3JiTG55nbItgapZEEI2Zsdcg6OmFtgGoMRH26462tHFfN PKn9peaeLAvKLhkzKQCIFHeLoHx0fT+XqrR1ITlZYBzAvTHsztAMqWbUj8qL5bIpf6Sn T13okfeZRUrKeu+3ig2xXW5trltyyo3a5yGeeE7u8gflGjU3Jg7HhCXK9H5dFJieD1h9 JCPF3ccZziWIviIdp5xH5V7K8y6391NvYAYgJQt16Lz+aYYbQ+O5okxWdDysxPwhzynj dYWxRLgiMRcQtteyCVypVtsOEa/6Dr7QIHpuHwU77bIcXqjaHxfZyohX0mUfbnwxZw/h iQpQ== X-Gm-Message-State: AOAM531sscWnD1MnSo6OUe7MtUKE3wRMwr3Eho5qycn8p/OMco+fR6P3 xlXLLmShU1j3pfEtObZbpPlmRycy8IE= X-Google-Smtp-Source: ABdhPJxvPyKtRGbVuOTSZ+N6NGcQgcjmTr2wqkxG6eA4SUPbQz95ybbMdKe+bPsN4nVgAXlH0g8J3Q== X-Received: by 2002:a05:6a00:1702:b0:50a:8181:fed7 with SMTP id h2-20020a056a00170200b0050a8181fed7mr16955898pfc.56.1650518641551; Wed, 20 Apr 2022 22:24:01 -0700 (PDT) Received: from localhost ([2406:7400:63:fca5:5639:1911:2ab6:cfe6]) by smtp.gmail.com with ESMTPSA id k11-20020a056a00168b00b004f7e1555538sm22787846pfc.190.2022.04.20.22.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 22:24:01 -0700 (PDT) From: Ritesh Harjani To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org Cc: Eric Biggers , Theodore Ts'o , Jan Kara , Ritesh Harjani Subject: [RFC 6/6] ext4: Use provided macro for checking dummy_enc_policy Date: Thu, 21 Apr 2022 10:53:22 +0530 Message-Id: <7ae6e9b0e700b494bcf2c92250a601b513d7e0c6.1650517532.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org We have a macro which test is dummy_enc_policy is enabled or not. Use that instead. Signed-off-by: Ritesh Harjani --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index e7e5c9c057d7..73fb54c3efd3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2685,7 +2685,7 @@ static int ext4_check_opt_consistency(struct fs_context *fc, * it to be specified during remount, but only if there is no change. */ if ((ctx->spec & EXT4_SPEC_DUMMY_ENCRYPTION) && - is_remount && !sbi->s_dummy_enc_policy.policy) { + is_remount && !DUMMY_ENCRYPTION_ENABLED(sbi)) { ext4_msg(NULL, KERN_WARNING, "Can't set test_dummy_encryption on remount"); return -1;