From: Eric Biggers <ebiggers@kernel.org>
To: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
"Theodore Y . Ts'o" <tytso@mit.edu>,
Jaegeuk Kim <jaegeuk@kernel.org>,
kernel-team@meta.com, linux-btrfs@vger.kernel.org,
linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH v6 5/8] fscrypt: reduce special-casing of IV_INO_LBLK_32
Date: Wed, 9 Aug 2023 23:57:38 -0700 [thread overview]
Message-ID: <20230810065738.GG923@sol.localdomain> (raw)
In-Reply-To: <542ea134771e2caa3043dfe48c2825d93495c626.1691505830.git.sweettea-kernel@dorminy.me>
On Tue, Aug 08, 2023 at 01:08:05PM -0400, Sweet Tea Dorminy wrote:
> Right now, the IV_INO_LBLK_32 policy is handled by its own function
> called in fscrypt_setup_v2_file_key(), different from all other policies
> which just call find_mode_prepared_key() with various parameters. The
> function additionally sets up the relevant inode hashing key in the
> master key, and uses it to hash the inode number if possible. This is
> not particularly relevant to setting up a prepared key, so this change
> tries to make it clear that every non-default policy uses basically the
> same setup mechanism for its prepared key. The other setup is moved to
> be called from the top crypt_info setup function.
>
> Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
It seems the goal of this patch is to finish the refactoring started by patches
2 and 4 of making fscrypt_setup_file_key() only set up the I/O key ("prepared
key"). The title and description don't make it very clear, though. I think a
better title would be the following which is analogous to patch 4:
fscrypt: move ino hashing setup away from IO key setup
BTW, it seems patch 3 should not be where it is in the series, since 2, 4, and 5
seem to be on one topic.
> +static int fscrypt_setup_ino_hash_key(struct fscrypt_master_key *mk)
> {
> int err;
err needs to be initialized to 0.
> + /*
> + * The IV_INO_LBLK_32 policy needs a hashed inode number, but new
> + * inodes may not have an inode number assigned yet.
> + */
> + if (policy->version == FSCRYPT_POLICY_V2 &&
> + (policy->v2.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)) {
> + res = fscrypt_setup_ino_hash_key(mk);
> + if (res)
> + goto out;
> +
> + if (inode->i_ino)
> + fscrypt_hash_inode_number(crypt_info, mk);
> + }
This seems to be another case where a comment was copied but it doesn't make as
much sense in the new context. How about the following:
/*
* If the file is using an IV_INO_LBLK_32 policy, derive the inode hash
* key if it wasn't done already. Then hash the inode number and cache
* the resulting hash. New inodes might not have an inode number
* assigned yet; hashing their inode number is delayed until later.
*/
- Eric
next prev parent reply other threads:[~2023-08-10 6:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 17:08 [PATCH v6 0/8] fscrypt: preliminary rearrangmeents of key setup Sweet Tea Dorminy
2023-08-08 17:08 ` [PATCH v6 1/8] fscrypt: move inline crypt decision to info setup Sweet Tea Dorminy
2023-08-09 17:19 ` Josef Bacik
2023-08-08 17:08 ` [PATCH v6 2/8] fscrypt: split and rename setup_file_encryption_key() Sweet Tea Dorminy
2023-08-09 17:19 ` Josef Bacik
2023-08-10 6:34 ` Eric Biggers
2023-08-08 17:08 ` [PATCH v6 3/8] fscrypt: split setup_per_mode_enc_key() Sweet Tea Dorminy
2023-08-09 17:22 ` Josef Bacik
2023-08-10 6:37 ` Eric Biggers
2023-08-08 17:08 ` [PATCH v6 4/8] fscrypt: move dirhash key setup away from IO key setup Sweet Tea Dorminy
2023-08-09 17:25 ` Josef Bacik
2023-08-08 17:08 ` [PATCH v6 5/8] fscrypt: reduce special-casing of IV_INO_LBLK_32 Sweet Tea Dorminy
2023-08-09 5:30 ` kernel test robot
2023-08-10 6:57 ` Eric Biggers [this message]
2023-08-08 17:08 ` [PATCH v6 6/8] fscrypt: move all the shared mode key setup deeper Sweet Tea Dorminy
2023-08-09 17:40 ` Josef Bacik
2023-08-10 7:03 ` Eric Biggers
2023-08-08 17:08 ` [PATCH v6 7/8] fscrypt: make infos have a pointer to prepared keys Sweet Tea Dorminy
2023-08-09 17:42 ` Josef Bacik
2023-08-08 17:08 ` [PATCH v6 8/8] fscrypt: make prepared keys record their type Sweet Tea Dorminy
2023-08-09 17:44 ` Josef Bacik
2023-08-10 4:54 ` Dan Carpenter
2023-08-10 7:19 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230810065738.GG923@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=jaegeuk@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=sweettea-kernel@dorminy.me \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).