All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Alberto Garcia <berto@igalia.com>
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 19:08:13 +0000	[thread overview]
Message-ID: <20261116190813.GA229817@google.com> (raw)
In-Reply-To: <avsP3xlSwVjj3GJh@igalia.com>

On Mon, Nov 16, 2026 at 03:14:55PM +0100, Alberto Garcia wrote:
> > > +	/* 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?

Yes, that sounds right.  If a bit flip enables EXT4_ENCRYPT_FL on an
inode, it will almost certainly trigger the NO_ENCRYPTION_POLICY case
(which clears EXT4_ENCRYPT_FL) or CORRUPT_ENCRYPTION_POLICY case (which
clears the inode).  This new check is after that, when the inode has
both EXT4_ENCRYPT_FL and a valid-looking xattr.  So setting the feature
flag there should be relatively safe.

- Eric

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

Thread overview: 4+ 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
2026-11-16 19:08     ` Eric Biggers [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=20261116190813.GA229817@google.com \
    --to=ebiggers@kernel.org \
    --cc=berto@igalia.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.