* [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set
@ 2024-02-01 0:35 xiubli
2024-02-01 2:48 ` Eric Biggers
0 siblings, 1 reply; 3+ messages in thread
From: xiubli @ 2024-02-01 0:35 UTC (permalink / raw)
To: linux-fscrypt
Cc: ebiggers, tytso, jaegeuk, linux-kernel, idryomov, ceph-devel,
jlayton, vshankar, mchangir, Xiubo Li
From: Xiubo Li <xiubli@redhat.com>
The inode->i_blkbits should be already set before calling
fscrypt_get_encryption_info() and it will use this to setup the
ci_data_unit_bits later.
URL: https://tracker.ceph.com/issues/64035
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
V2:
- Fixed the comments suggested by Eric, thanks.
fs/crypto/keysetup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
index d71f7c799e79..9a0a40c81bf2 100644
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -687,7 +687,7 @@ 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.
+ * @inode: the new inode. ->i_mode and ->i_blkbits must be set already.
* ->i_ino doesn't need to be set yet.
* @encrypt_ret: (output) set to %true if the new inode will be encrypted
*
@@ -717,6 +717,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;
+
if (WARN_ON_ONCE(inode->i_mode == 0))
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set
2024-02-01 0:35 [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set xiubli
@ 2024-02-01 2:48 ` Eric Biggers
2024-02-01 2:59 ` Xiubo Li
0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2024-02-01 2:48 UTC (permalink / raw)
To: xiubli
Cc: linux-fscrypt, tytso, jaegeuk, linux-kernel, idryomov,
ceph-devel, jlayton, vshankar, mchangir
On Thu, Feb 01, 2024 at 08:35:25AM +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 use this to setup the
> ci_data_unit_bits later.
>
> URL: https://tracker.ceph.com/issues/64035
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
Thanks, applied. I adjusted the commit message to make it clear what the patch
actually does:
commit 5befc19caec93f0088595b4d28baf10658c27a0f
Author: Xiubo Li <xiubli@redhat.com>
Date: Thu Feb 1 08:35:25 2024 +0800
fscrypt: explicitly require that inode->i_blkbits be set
Document that fscrypt_prepare_new_inode() requires inode->i_blkbits to
be set, and make it WARN if it's not. This would have made the CephFS
bug https://tracker.ceph.com/issues/64035 a bit easier to debug.
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Link: https://lore.kernel.org/r/20240201003525.1788594-1-xiubli@redhat.com
Signed-off-by: Eric Biggers <ebiggers@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set
2024-02-01 2:48 ` Eric Biggers
@ 2024-02-01 2:59 ` Xiubo Li
0 siblings, 0 replies; 3+ messages in thread
From: Xiubo Li @ 2024-02-01 2:59 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-fscrypt, tytso, jaegeuk, linux-kernel, idryomov,
ceph-devel, jlayton, vshankar, mchangir
On 2/1/24 10:48, Eric Biggers wrote:
> On Thu, Feb 01, 2024 at 08:35:25AM +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 use this to setup the
>> ci_data_unit_bits later.
>>
>> URL: https://tracker.ceph.com/issues/64035
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> Thanks, applied. I adjusted the commit message to make it clear what the patch
> actually does:
>
> commit 5befc19caec93f0088595b4d28baf10658c27a0f
> Author: Xiubo Li <xiubli@redhat.com>
> Date: Thu Feb 1 08:35:25 2024 +0800
>
> fscrypt: explicitly require that inode->i_blkbits be set
>
> Document that fscrypt_prepare_new_inode() requires inode->i_blkbits to
> be set, and make it WARN if it's not. This would have made the CephFS
> bug https://tracker.ceph.com/issues/64035 a bit easier to debug.
>
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> Link: https://lore.kernel.org/r/20240201003525.1788594-1-xiubli@redhat.com
> Signed-off-by: Eric Biggers <ebiggers@google.com>
>
Ack, thanks Eric.
- Xiubo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-01 2:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 0:35 [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set xiubli
2024-02-01 2:48 ` Eric Biggers
2024-02-01 2:59 ` Xiubo Li
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).