Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3648174iob; Mon, 2 May 2022 01:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMesw2X3CiGHVqgH5UpxCf8DeUjzdTKTwg8LyDZ6BxAQePB92Im5TD3a9qYQN5rssuogQi X-Received: by 2002:a05:6a00:1687:b0:4e1:45d:3ded with SMTP id k7-20020a056a00168700b004e1045d3dedmr10604043pfc.0.1651481386373; Mon, 02 May 2022 01:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651481386; cv=none; d=google.com; s=arc-20160816; b=nKpfZ9HBt0XwOIgQnZO5cisO3CeRX29fgzdhQgmCJRdIh31xLEAt6BvMmDTRRvcSj/ rDCf8lJpIgcCGJDAXAK5SQz4jQU9RN12qbmzEKiX1Mry/bNk9/4vIVAsAEQ1AR8KLli/ GV5r9UokLEpwjhtHx67yfjzvP41wmvJKtSei3l4f6do5hKVmJ7jFw9FR9Zo/7HrLfM/N VwM3JSuigLvT1L773il0kYFrGZocXvrJ9x7cFtv11n/oP6TC+gx9gSt9tTPaGfgF/sQc WfkW+cwWK5HSlD1YCobxM/y/1dx0In0/apcixg2KLxyEASPBi3cXafDVp2j+DBFT/vVR iomg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tqLNBrHNJGOLVHKWaIyFqpr8kilTjAU8fwxdtntnuo0=; b=MMn6e9Sj65G4T7rjITJdR3loM+cKHAhx4oQLbItRzy7qhfD1oYkDsCYVokwc3RT41Z In5JpcjFJ2+sv01TyQkMpPjE0rH3kaQ9y8Ub5jnaQE/pG56ejQGVaZlUj29SAKbN4imI kTIm/Nlp8FzvZ/StcmbSO1s+xK5CbdcrVmPCIAQgGaXoN7YQK7WpMPuY7QctRR/o5Qh3 p0C45F86oZZmKuFlNzIh+NtA45KJqhvQHVNxL2ztUW6JXKxmYLaiKTRAWISHyDSo11k0 CgLGkJ6uz/GEUpzDHrIWdAg0AOWQAarP5S+5XpC5jvTV1cZcrQO6DBWvE7AiBtyMbfyQ nghA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=czXM3Mcf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13-20020a170902cf0d00b0015d50baea7dsi14439143plg.212.2022.05.02.01.49.26; Mon, 02 May 2022 01:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=czXM3Mcf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S240562AbiEAFQa (ORCPT + 99 others); Sun, 1 May 2022 01:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240674AbiEAFQS (ORCPT ); Sun, 1 May 2022 01:16:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B3A506F0; Sat, 30 Apr 2022 22:12:54 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0464DB80CDB; Sun, 1 May 2022 05:12:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86F20C385B2; Sun, 1 May 2022 05:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651381968; bh=miRma4LpgMJ8145QGIGH87Z+R/bPOmgH/Fe9h/IwTn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czXM3McfZVhZDclBL2XeUoocs7vKzKavmpxjE4XY4JRjaWptmpKQCLXtHXo4ytnVK BAv1j8W73tI0TMXd6pD15396Y++3yI7dP8GRFWTbBUTzw2P5MFzHewhQYDqrZd+b/l 7rNntTTRAzWbFkkofLvoVlGUL4NlOvqfIS2B2wCxNxMm6ppktA/1H0CWZdX+98K+Yg JOKU/+BWSQhIaDdZJCu5xR9sZfz/PQ1yUucw92SAo6ox0RHjfbVEVhBxOdP3RZaIj+ N4qexuGTg1fT7RWmIatgLxOQF24AotVKcXXHXXvOypHjQ6bM5b3ZbiPpNsdkcQENUn ymKzzIhXeLzCg== From: Eric Biggers To: linux-fscrypt@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Lukas Czerner , Theodore Ts'o , Jaegeuk Kim , Jeff Layton Subject: [PATCH v2 6/7] f2fs: use the updated test_dummy_encryption helper functions Date: Sat, 30 Apr 2022 22:08:56 -0700 Message-Id: <20220501050857.538984-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220501050857.538984-1-ebiggers@kernel.org> References: <20220501050857.538984-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-ext4@vger.kernel.org From: Eric Biggers Switch f2fs over to the functions that are replacing fscrypt_set_test_dummy_encryption(). Since f2fs hasn't been converted to the new mount API yet, this doesn't really provide a benefit for f2fs. But it allows fscrypt_set_test_dummy_encryption() to be removed. Also take the opportunity to eliminate an #ifdef. Signed-off-by: Eric Biggers --- fs/f2fs/super.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 6f69491aa5731..c08cbe0dfcd85 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -492,9 +493,19 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb, bool is_remount) { struct f2fs_sb_info *sbi = F2FS_SB(sb); -#ifdef CONFIG_FS_ENCRYPTION + struct fs_parameter param = { + .type = fs_value_is_string, + .string = arg->from ? arg->from : "", + }; + struct fscrypt_dummy_policy *policy = + &F2FS_OPTION(sbi).dummy_enc_policy; int err; + if (!IS_ENABLED(CONFIG_FS_ENCRYPTION)) { + f2fs_warn(sbi, "test_dummy_encryption option not supported"); + return -EINVAL; + } + if (!f2fs_sb_has_encrypt(sbi)) { f2fs_err(sbi, "Encrypt feature is off"); return -EINVAL; @@ -506,12 +517,12 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb, * needed to allow it to be set or changed during remount. We do allow * it to be specified during remount, but only if there is no change. */ - if (is_remount && !F2FS_OPTION(sbi).dummy_enc_policy.policy) { + if (is_remount && !fscrypt_is_dummy_policy_set(policy)) { f2fs_warn(sbi, "Can't set test_dummy_encryption on remount"); return -EINVAL; } - err = fscrypt_set_test_dummy_encryption( - sb, arg->from, &F2FS_OPTION(sbi).dummy_enc_policy); + + err = fscrypt_parse_test_dummy_encryption(¶m, policy); if (err) { if (err == -EEXIST) f2fs_warn(sbi, @@ -524,12 +535,14 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb, opt, err); return -EINVAL; } + err = fscrypt_add_test_dummy_key(sb, policy); + if (err) { + f2fs_warn(sbi, "Error adding test dummy encryption key [%d]", + err); + return err; + } f2fs_warn(sbi, "Test dummy encryption mode enabled"); return 0; -#else - f2fs_warn(sbi, "test_dummy_encryption option not supported"); - return -EINVAL; -#endif } #ifdef CONFIG_F2FS_FS_COMPRESSION -- 2.36.0