fscrypt: to make sure the inode->i_blkbits is correctly set
PATCH v2 1/1 fscrypt: to make sure the inode->i_blkbits is correctly set
From: Xiubo Li <[email protected]>
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
---
V2:
- Fixed the comments suggested by Eric, thanks.
fs/crypto/keysetup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/crypto/keysetup.c +4 -1
@@ -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 ;
Signature · 1 line
2.43.0
Quoted 8 lines · On Thu, Feb 01, 2024 at 08:35:25AM +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
The
inode->i_blkbitsshould be already set before callingfscrypt_get_encryption_info()and it will use this to setup theci_data_unit_bitslater.URL: https://tracker.ceph.com/issues/64035
Signed-off-by Xiubo Li <[email protected]>
Thanks, applied. I adjusted the commit message to make it clear what the patch actually does:
commit 5befc19caec93f0088595b4d28baf10658c27a0f
Author: Xiubo Li <[email protected]> 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.
Quoted 18 lines · Eric Biggers
Quoted 8 lines · On Thu, Feb 01, 2024 at 08:35:25AM +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
The
inode->i_blkbitsshould be already set before callingfscrypt_get_encryption_info()and it will use this to setup theci_data_unit_bitslater.URL: https://tracker.ceph.com/issues/64035
Signed-off-by Xiubo Li <[email protected]>Thanks, applied. I adjusted the commit message to make it clear what the patch actually does:
commit
5befc19caec93f0088595b4d28baf10658c27a0fAuthor: Xiubo Li <[email protected]> Date: Thu Feb 1 08:35:25 2024 +0800fscrypt: explicitly require that
inode->i_blkbitsbe set
Quoted 8 lines
Document that
fscrypt_prepare_new_inode()requiresinode->i_blkbitsto 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 <[email protected]>Signed-off-by Eric Biggers <[email protected]>
Ack, thanks Eric.
- Xiubo