From: sashiko-bot@kernel.org
To: "Baokun Li" <libaokun@linux.alibaba.com>, linux-fscrypt@vger.kernel.org
Cc: ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu,
linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca,
jack@suse.cz, yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Subject: Re: [PATCH 2/4] fscrypt: Validate the test_dummy_encryption policy for new inodes
Date: Tue, 03 Nov 2026 15:45:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-195647@kernel.org> (raw)
In-Reply-To: <20261103153132.4154855-3-libaokun@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] fscrypt: missed S_CASEFOLD check in fscrypt_prepare_new_inode()
--
commit fa704dc171d6c1edb5f7cea48ff46447da451c52
Author: Baokun Li <libaokun@linux.alibaba.com>
fscrypt: Validate the test_dummy_encryption policy for new inodes
This commit validates the test_dummy_encryption policy in
fscrypt_prepare_new_inode() when creating a new inode in an unencrypted
directory so that unsupported policies are rejected before being applied.
> diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
> index a77b889d7578c..497ba67ec6fed 100644
> --- a/fs/crypto/keysetup.c
> +++ b/fs/crypto/keysetup.c
> @@ -763,6 +763,14 @@ int fscrypt_prepare_new_inode(struct inode *dir, struct inode *inode,
> !S_ISLNK(inode->i_mode))
> return 0;
>
> + /*
> + * A policy inherited from an encrypted directory was validated
> + * when the directory's key was set up. The test dummy policy was
> + * not, so check it here.
> + */
> + if (!IS_ENCRYPTED(dir) && !fscrypt_supported_policy(policy, inode))
> + return -EINVAL;
[Severity: Medium]
Does fscrypt_supported_policy(policy, inode) miss the casefold check when
creating a new subdirectory inside an unencrypted, casefolded directory with
test_dummy_encryption=v1?
When fscrypt_prepare_new_inode() is called by __ext4_new_inode() or
f2fs_new_inode(), only inode->i_mode and inode->i_blkbits are set on the new
inode. The filesystem has not yet inherited the casefold flag from dir or set
S_CASEFOLD on inode->i_flags, which is why fscrypt_prepare_new_inode() checks
IS_CASEFOLDED(dir) && S_ISDIR(inode->i_mode) just below:
return fscrypt_setup_encryption_info(inode, policy, nonce,
IS_CASEFOLDED(dir) &&
S_ISDIR(inode->i_mode));
However, fscrypt_supported_policy() -> fscrypt_supported_v1_policy() checks
IS_CASEFOLDED(inode):
if (IS_CASEFOLDED(inode)) {
/* With v1, there's no way to derive dirhash keys. */
fscrypt_warn(inode,
"v1 policies can't be used on casefolded directories");
return false;
}
Since IS_CASEFOLDED(inode) is still false at this point, creating a
subdirectory in an unencrypted casefolded directory under
test_dummy_encryption=v1 passes validation and creates a v1-encrypted,
casefolded directory without an initialized dirhash key, triggering
WARN_ON_ONCE(!ci->ci_dirhash_key_initialized) in fscrypt_fname_siphash() on
subsequent lookups or creations.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103153132.4154855-1-libaokun@linux.alibaba.com?part=2
next prev parent reply other threads:[~2026-11-03 15:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:31 [PATCH 0/4] ext4: support encryption with block size larger than page size Baokun Li
2026-11-03 15:31 ` [PATCH 1/4] fscrypt: Cap data units at the " Baokun Li
2026-11-03 15:44 ` sashiko-bot
2026-11-03 22:40 ` Eric Biggers
2026-11-03 15:31 ` [PATCH 2/4] fscrypt: Validate the test_dummy_encryption policy for new inodes Baokun Li
2026-11-03 15:45 ` sashiko-bot [this message]
2026-11-03 15:31 ` [PATCH 3/4] ext4: don't put a DUN wraparound in the middle of a read bio Baokun Li
2026-11-03 15:40 ` sashiko-bot
2026-11-03 15:31 ` [PATCH 4/4] ext4: allow large folios and bs > ps encryption Baokun Li
2026-11-03 15:42 ` sashiko-bot
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=sashiko-outbox-195647@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=ebiggers@kernel.org \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
/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