From: Xiubo Li <xiubli@redhat.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fscrypt@vger.kernel.org, tytso@mit.edu, jaegeuk@kernel.org,
linux-kernel@vger.kernel.org, idryomov@gmail.com,
ceph-devel@vger.kernel.org, jlayton@kernel.org,
vshankar@redhat.com
Subject: Re: [PATCH] fscrypt: to make sure the inode->i_blkbits is correctly set
Date: Thu, 1 Feb 2024 08:26:02 +0800 [thread overview]
Message-ID: <6cc9dca0-52f6-44f8-87d4-9a937e3f83e6@redhat.com> (raw)
In-Reply-To: <20240127063754.GA11935@sol.localdomain>
On 1/27/24 14:37, Eric Biggers wrote:
> On Thu, Jan 25, 2024 at 12:48:25PM +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> The inode->i_blkbits should be already set before calling
>> fscrypt_get_encryption_info() and it will be used this to setup the
>> ci_data_unit_bits.
>>
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>> fs/crypto/keysetup.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
>> index d71f7c799e79..909187e52bae 100644
>> --- a/fs/crypto/keysetup.c
>> +++ b/fs/crypto/keysetup.c
>> @@ -702,6 +702,9 @@ int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported)
>> /**
>> * fscrypt_prepare_new_inode() - prepare to create a new inode in a directory
>> * @dir: a possibly-encrypted directory
>> * @inode: the new inode. ->i_mode must be set already.
>> * ->i_ino doesn't need to be set yet.
> Maybe just change the above to "->i_mode and ->i_blkbits", instead of adding a
> separate paragraph?
Just back from PTO.
Yeah, this sounds much better. I will fix it.
Thanks
- Xiubo
>> * @encrypt_ret: (output) set to %true if the new inode will be encrypted
>> *
>> * If the directory is encrypted, set up its ->i_crypt_info in preparation for
>> * encrypting the name of the new file. Also, if the new inode will be
>> * encrypted, set up its ->i_crypt_info and set *encrypt_ret=true.
>> *
>> * This isn't %GFP_NOFS-safe, and therefore it should be called before starting
>> * any filesystem transaction to create the inode. For this reason, ->i_ino
>> * isn't required to be set yet, as the filesystem may not have set it yet.
>> *
>> * This doesn't persist the new inode's encryption context. That still needs to
>> * be done later by calling fscrypt_set_context().
>> *
>> + * Please note that the inode->i_blkbits should be already set before calling
>> + * this and later it will be used to setup the ci_data_unit_bits.
>> + *
>> * Return: 0 on success, -ENOKEY if the encryption key is missing, or another
>> * -errno code
>> */
>> @@ -717,6 +720,9 @@ int fscrypt_prepare_new_inode(struct inode *dir, struct inode *inode,
>> if (IS_ERR(policy))
>> return PTR_ERR(policy);
>>
>> + if (WARN_ON_ONCE(inode->i_blkbits == 0))
>> + return -EINVAL;
>> +
> Thanks,
>
> - Eric
>
prev parent reply other threads:[~2024-02-01 0:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 4:48 [PATCH] fscrypt: to make sure the inode->i_blkbits is correctly set xiubli
2024-01-27 6:37 ` Eric Biggers
2024-02-01 0:26 ` Xiubo Li [this message]
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=6cc9dca0-52f6-44f8-87d4-9a937e3f83e6@redhat.com \
--to=xiubli@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=ebiggers@kernel.org \
--cc=idryomov@gmail.com \
--cc=jaegeuk@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=vshankar@redhat.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).