From patchwork Sun Jul 9 18:53:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13306031 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 6DB4EC001DE for ; Sun, 9 Jul 2023 18:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbjGISxa (ORCPT ); Sun, 9 Jul 2023 14:53:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjGISxT (ORCPT ); Sun, 9 Jul 2023 14:53:19 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABC7A10C; Sun, 9 Jul 2023 11:53:16 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id EAB7780AE5; Sun, 9 Jul 2023 14:53:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688928796; bh=g0b35MrtF2uGyl8iDzN5bX4Wn/xb7o1sAgwZ2In2a1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUeDIAkH5XC1eYu/AXfveKRO/5XacnBp/UhgpqpVXLQe5AmISySingz5JXdYP69JZ cg7oaySnlXEWMDM/sYL50tUm6YxnfajQF/QRVDg7mVUJ3ozBiZqVJPdaI/bUtFZt31 Voq7Fy2kwumbVo0BQWYQa7mEOjtbxtNeLjT5ZSfhHk9RLkk5Z5XNYOO4QGz7uvVFTw p/bB9BLgr8wecauPNbstsynNe+u5zE5eiOIjh3NLW3QUW+9VmET6JlItJ8oRMwnkND CMGX72CFHRfMFp6RU+M5i4PKgIAGkFpxmD6lsvVGaSSCSedSdnzHjg1166Y7mt67Zk AecCGFHpEV98w== From: Sweet Tea Dorminy To: "Theodore Y. Ts'o" , Jaegeuk Kim , Eric Biggers , Chris Mason , Josef Bacik , David Sterba , linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH v5 1/8] fscrypt: move inline crypt decision to info setup Date: Sun, 9 Jul 2023 14:53:01 -0400 Message-Id: <5f8bf550b27040b9631c3d9c063847b8a7d6cba6.1688927423.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org setup_file_encryption_key() is doing a lot of things at the moment -- setting the crypt_info's inline encryption bit, finding and locking a master key, and calling the functions to get the appropriate prepared key for this info. Since setting the inline encryption bit has nothing to do with finding the master key, it's easy and hopefully clearer to select the encryption implementation in fscrypt_setup_encryption_info(), the main fscrypt_info setup function, instead of in setup_file_encryption_key() which will long-term only deal in setting up the prepared key for the info. Signed-off-by: Sweet Tea Dorminy --- fs/crypto/keysetup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 361f41ef46c7..b89c32ad19fb 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -443,10 +443,6 @@ static int setup_file_encryption_key(struct fscrypt_info *ci, struct fscrypt_master_key *mk; int err; - err = fscrypt_select_encryption_impl(ci); - if (err) - return err; - err = fscrypt_policy_to_key_spec(&ci->ci_policy, &mk_spec); if (err) return err; @@ -580,6 +576,10 @@ fscrypt_setup_encryption_info(struct inode *inode, WARN_ON_ONCE(mode->ivsize > FSCRYPT_MAX_IV_SIZE); crypt_info->ci_mode = mode; + res = fscrypt_select_encryption_impl(crypt_info); + if (res) + goto out; + res = setup_file_encryption_key(crypt_info, need_dirhash_key, &mk); if (res) goto out;