Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
	Baokun Li <libaokun@linux.alibaba.com>
Subject: Re: [PATCH] e2fsck: set the encrypt feature if the filesystem has encrypted inodes
Date: Mon, 16 Nov 2026 15:14:55 +0100	[thread overview]
Message-ID: <avsP3xlSwVjj3GJh@igalia.com> (raw)
In-Reply-To: <20261113202745.GA29151@quark>

On Fri, Nov 13, 2026 at 12:27:45PM -0800, Eric Biggers wrote:
> A few comments on the diff:
> 
> >  tests/f_encrypt_feature_missing/image.gz   | Bin 0 -> 5566 bytes
> 
> This image has a 4096-byte block of incompressible ciphertext in it.
> An empty file would exercise this new code just as well and result
> in a filesystem image of around 1.5 KB.

Sounds good, I'll update the test.

> > @@ -389,6 +389,13 @@ int add_encrypted_file(e2fsck_t ctx, struct problem_context *pctx)
> >  		return 0;
> 
> The function comment of add_encrypted_file() should be updated to
> mention the new behavior.

Done.

> > +	/* The inode is encrypted, so the filesystem needs the encrypt feature */
> > +	if (!ext2fs_has_feature_encrypt(ctx->fs->super) &&
> > +	    fix_problem(ctx, PR_1_ENCRYPT_FEATURE, pctx)) {
> > +		ext2fs_set_feature_encrypt(ctx->fs->super);
> > +		ext2fs_mark_super_dirty(ctx->fs);
> > +	}
> 
> I'm a little surprised the fix is to set the feature flag, rather
> than clear the inode.  It looks like e2fsck does this for other
> feature flags though, so I guess this is consistent with that.

That's also what I understood from the previous conversation at
https://lore.kernel.org/linux-ext4/armU51iuvA9d7zvR@igalia.com/

So this patch assumes that the inode is correctly encrypted but the
feature flag is missing (because it was accidentally removed or
something).

A different situation would be if the inode has the encryption flag
when it shouldn't, but the basic case is already handled by e2fsck
(would we need an additional test for this?):

# dd if=/dev/zero of=image bs=4096 count=128
# mke2fs -b 4096 -N 128 image
# debugfs -w -R "mkdir edir" image
# debugfs -w -R "sif edir flags 0x800" image
# e2fsck -vf image
e2fsck 1.47.4 (6-Mar-2025)
Pass 1: Checking inodes, blocks, and sizes
Inode 12 has encrypt flag but no encryption extended attribute.
Clear flag<y>?

Other possibilities:

- The flag is set, the xattr is corrupt: this is already checked
  (immediately before the code added by this patch).
- The flag is unset, the xattr is present: this situation is
  not detected, but I don't think it has any consequences?
- The flag is set, the xattr seems valid (or unknown) although the
  file is not supposed to be encrypted. This is the only problematic
  case, here e2fsck would suggest to set the feature flag. But this
  looks like a very unlikely scenario, or am I missing something?

> Given that it's done this way, though, let's consider the case
> where the user declines to fix this problem, either interactively
> or via 'e2fsck -n'.  In that case, the problem gets reported for
> all thousands/millions of inodes that could have the problem.
> Perhaps it should be reported only for the first, by checking
> 'info->file_ranges_count == 0'?

Yes, I think that's a good idea, thanks for the suggestion.

> > +	/*
> > +	 * Encrypted inode found but the filesystem is missing the
> > +	 * encrypt feature
> > +	 */
> > +	{ PR_1_ENCRYPT_FEATURE,
> > +	  N_("@i %i is encrypted but @S is missing ENCRYPT feature\n"),
> > +	  PROMPT_FIX, PR_PREEN_OK, 0, 0, 0 },
> 
> Isn't this missing '/* xgettext:no-c-format */'?

Hmmm... I think you're right, and it looks like there are more strings
with this problem on the same file. I was using other entries as an
example and I didn't notice this.

Berto

      reply	other threads:[~2026-11-16 14:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 16:21 [PATCH] e2fsck: set the encrypt feature if the filesystem has encrypted inodes Alberto Garcia
2026-11-13 20:27 ` Eric Biggers
2026-11-16 14:14   ` Alberto Garcia [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=avsP3xlSwVjj3GJh@igalia.com \
    --to=berto@igalia.com \
    --cc=ebiggers@kernel.org \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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