* [PATCH v2] ext4: fix journal credit check when setting fscrypt context
@ 2026-02-07 9:53 Simon Weber
2026-02-13 0:07 ` Eric Biggers
2026-03-26 11:57 ` Theodore Ts'o
0 siblings, 2 replies; 5+ messages in thread
From: Simon Weber @ 2026-02-07 9:53 UTC (permalink / raw)
To: linux-kernel, linux-ext4, tytso, adilger.kernel
Cc: Simon Weber, tahsin, ebiggers, Anthony Durrer
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.
Fixes: c1a5d5f6ab21eb7e ("ext4: improve journal credit handling in set xattr paths")
Co-developed-by: Anthony Durrer <anthonydev@fastmail.com>
Signed-off-by: Anthony Durrer <anthonydev@fastmail.com>
Signed-off-by: Simon Weber <simon.weber.39@gmail.com>
---
fs/ext4/crypto.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
index cf0a0970c095..a89a14dffa48 100644
--- a/fs/ext4/crypto.c
+++ b/fs/ext4/crypto.c
@@ -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,
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ext4: fix journal credit check when setting fscrypt context
2026-02-07 9:53 [PATCH v2] ext4: fix journal credit check when setting fscrypt context Simon Weber
@ 2026-02-13 0:07 ` Eric Biggers
2026-02-22 8:11 ` Simon Weber
2026-03-26 11:57 ` Theodore Ts'o
1 sibling, 1 reply; 5+ messages in thread
From: Eric Biggers @ 2026-02-13 0:07 UTC (permalink / raw)
To: Simon Weber
Cc: linux-kernel, linux-ext4, tytso, adilger.kernel, tahsin,
Anthony Durrer
On Sat, Feb 07, 2026 at 10:53:03AM +0100, Simon Weber wrote:
> 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.
> + */
Typo: reamining => remaining
Otherwise this looks good.
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
- Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ext4: fix journal credit check when setting fscrypt context
2026-02-13 0:07 ` Eric Biggers
@ 2026-02-22 8:11 ` Simon Weber
2026-02-22 20:28 ` Eric Biggers
0 siblings, 1 reply; 5+ messages in thread
From: Simon Weber @ 2026-02-22 8:11 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-kernel, linux-ext4, tytso, adilger.kernel, tahsin,
Anthony Durrer
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ext4: fix journal credit check when setting fscrypt context
2026-02-22 8:11 ` Simon Weber
@ 2026-02-22 20:28 ` Eric Biggers
0 siblings, 0 replies; 5+ messages in thread
From: Eric Biggers @ 2026-02-22 20:28 UTC (permalink / raw)
To: Simon Weber
Cc: linux-kernel, linux-ext4, tytso, adilger.kernel, tahsin,
Anthony Durrer
On Sun, Feb 22, 2026 at 09:11:55AM +0100, Simon Weber wrote:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ext4: fix journal credit check when setting fscrypt context
2026-02-07 9:53 [PATCH v2] ext4: fix journal credit check when setting fscrypt context Simon Weber
2026-02-13 0:07 ` Eric Biggers
@ 2026-03-26 11:57 ` Theodore Ts'o
1 sibling, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2026-03-26 11:57 UTC (permalink / raw)
To: linux-kernel, linux-ext4, adilger.kernel, Simon Weber
Cc: Theodore Ts'o, tahsin, ebiggers, Anthony Durrer
On Sat, 07 Feb 2026 10:53:03 +0100, Simon Weber wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] ext4: fix journal credit check when setting fscrypt context
commit: cb8c10c17a8b339423cd950a04841c5b3287f346
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-26 11:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-07 9:53 [PATCH v2] ext4: fix journal credit check when setting fscrypt context Simon Weber
2026-02-13 0:07 ` Eric Biggers
2026-02-22 8:11 ` Simon Weber
2026-02-22 20:28 ` Eric Biggers
2026-03-26 11:57 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox