ext4: fix journal credit check when setting fscrypt context
PATCH v2 1/1 ext4: fix journal credit check when setting fscrypt context
Fix an issue arising when ext4 features has_journal, ea_inode, and encrypt are activated simultaneously, leading to ENOSPC when creating an encrypted file.
Fix by passing XATTR_CREATE flag to xattr_set_handle function if a handle is specified, i.e., when the function is called in the control flow of creating a new inode. This aligns the number of jbd2 credits set_handle checks for with the number allocated for creating a new inode.
ext4_set_context must not be called with a non-null handle (fs_data) if fscrypt context xattr is not guaranteed to not exist yet. The only other usage of this function currently is when handling the ioctl FS_IOC_SET_ENCRYPTION_POLICY, which calls it with fs_data=NULL.
--- fs/ext4/crypto.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ext4/crypto.c +6 -1
@@ -163,10 +163,15 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,*/ if (handle) { +/* +* Since the inode is new it is ok to pass the XATTR_CREATE flag. This +* is necessary to match the reamining journal credits check in the +* set_handle function with the credits allocated for the new inode. +*/ res =ext4_xattr_set_handle (handle, inode,EXT4_XATTR_INDEX_ENCRYPTION ,EXT4_XATTR_NAME_ENCRYPTION_CONTEXT , - ctx, len,0 ); + ctx, len,XATTR_CREATE );if (!res) {ext4_set_inode_flag (inode,EXT4_INODE_ENCRYPT ); ext4_clear_inode_state(inode,
Signature · 1 line
2.49.0
fs/ext4/crypto.c static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, · line 170
Quoted 6 lines · Simon Weber
fs/ext4/crypto.c +5
-0if (handle) { +/* +* Since the inode is new it is ok to pass the XATTR_CREATE flag. This +* is necessary to match the reamining journal credits check in the +* set_handle function with the credits allocated for the new inode. +*/
Typo: reamining => remaining
Otherwise this looks good.
- Eric
Hi Eric,
thanks for your approval.
How do we continue from here? Do I have to resubmit a patch with the typo fixed or can it just be fixed on the maintainer's side? If I resubmit, I should include your Reviewed-by tag at the bottom, correct?
Cheers,
Simon
Quoted 11 lines · Simon Weber
Hi Eric,
thanks for your approval.
How do we continue from here? Do I have to resubmit a patch with the typo fixed or can it just be fixed on the maintainer's side? If I resubmit, I should include your Reviewed-by tag at the bottom, correct?
Cheers,
Simon
This should get taken through the ext4 tree eventually. You don't need to resend the patch just for a typo and Reviewed-by.
- Eric
Quoted 10 lines · Simon Weber
Fix an issue arising when ext4 features
has_journal,ea_inode, and encrypt are activated simultaneously, leading to ENOSPC when creating an encrypted file.Fix by passing
XATTR_CREATEflag toxattr_set_handlefunction if a handle is specified, i.e., when the function is called in the control flow of creating a new inode. This aligns the number of jbd2 creditsset_handlechecks for with the number allocated for creating a new inode.[...]
Applied, thanks!
[1/1] ext4: fix journal credit check when setting fscrypt context
commit: cb8c10c17a8b339423cd950a04841c5b3287f346
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>