From: Eric Biggers <ebiggers@kernel.org>
To: shyckless@gmail.com
Cc: tytso@mit.edu, jaegeuk@kernel.org, linux-kernel@vger.kernel.org,
linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH v2] fscrypt: Don't set a policy on immutable or append-only directories
Date: Tue, 24 Nov 2026 15:08:06 -0800 [thread overview]
Message-ID: <20261124230806.GA2001@quark> (raw)
In-Reply-To: <20261120-fscrypt-v2-1-fb752135ea32@gmail.com>
On Fri, Nov 20, 2026 at 04:26:54AM +0000, Suyuan Wang via B4 Relay wrote:
> From: Suyuan Wang <stevewong@hust.edu.cn>
>
> FS_IOC_SET_ENCRYPTION_POLICY stores an encryption context in the
> directory (an xattr on ext4 and f2fs) and marks the inode as encrypted.
> fscrypt_ioctl_set_policy() checks inode_owner_or_capable(), but not the
> immutable or append-only inode flags, so the ioctl also succeeds on a
> directory with one of those flags set. Setting any other xattr on the
> same directory fails with -EPERM in may_write_xattr(), and
> FS_IOC_ENABLE_VERITY refuses such files as well.
>
> For example, on ext4 with the encrypt feature:
>
> mkdir d && chattr +i d
> setfattr -n user.x -v 1 d -> Operation not permitted
> FS_IOC_SET_ENCRYPTION_POLICY on d -> succeeds, d now has a policy
>
> Return -EPERM for an immutable or append-only directory before setting
> the policy, as may_write_xattr() does. Calls that find the same policy
> already set still return 0, since they don't change the inode. Update
> the documented EPERM cases to match.
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
> Fixes: f424f664f0e8 ("f2fs crypto: add encryption policy and password salt support")
> Cc: stable@vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Applied to https://git.kernel.org/pub/scm/fs/fscrypt/linux.git/log/?h=for-next
- Eric
prev parent reply other threads:[~2026-11-24 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 4:26 [PATCH v2] fscrypt: Don't set a policy on immutable or append-only directories Suyuan Wang via B4 Relay
2026-11-20 4:26 ` Suyuan Wang
2026-11-24 23: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=20261124230806.GA2001@quark \
--to=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shyckless@gmail.com \
--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.