Skip to content

Commit f000223

Browse files
committed
fscrypt: restrict IV_INO_LBLK_* to AES-256-XTS
IV_INO_LBLK_* exist only because of hardware limitations, and currently the only known use case for them involves AES-256-XTS. Therefore, for now only allow them in combination with AES-256-XTS. This way we don't have to worry about them being combined with other encryption modes. (To be clear, combining IV_INO_LBLK_* with other encryption modes *should* work just fine. It's just not being tested, so we can't be 100% sure it works. So with no known use case, it's best to disallow it for now, just like we don't allow other weird combinations like AES-256-XTS contents encryption with Adiantum filenames encryption.) This can be relaxed later if a use case for other combinations arises. Fixes: b103fb7 ("fscrypt: add support for IV_INO_LBLK_64 policies") Fixes: e3b1078 ("fscrypt: add support for IV_INO_LBLK_32 policies") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 1d6217a commit f000223

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/crypto/policy.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
7777
struct super_block *sb = inode->i_sb;
7878
int ino_bits = 64, lblk_bits = 64;
7979

80+
/*
81+
* IV_INO_LBLK_* exist only because of hardware limitations, and
82+
* currently the only known use case for them involves AES-256-XTS.
83+
* That's also all we test currently. For these reasons, for now only
84+
* allow AES-256-XTS here. This can be relaxed later if a use case for
85+
* IV_INO_LBLK_* with other encryption modes arises.
86+
*/
87+
if (policy->contents_encryption_mode != FSCRYPT_MODE_AES_256_XTS) {
88+
fscrypt_warn(inode,
89+
"Can't use %s policy with contents mode other than AES-256-XTS",
90+
type);
91+
return false;
92+
}
93+
8094
/*
8195
* It's unsafe to include inode numbers in the IVs if the filesystem can
8296
* potentially renumber inodes, e.g. via filesystem shrinking.

0 commit comments

Comments
 (0)