Skip to contentSkip to conversation

fscrypt: restrict IV_INO_LBLK_* to AES-256-XTS

PATCH Applied Eric Biggers 1 participant 2 messages Jul 21, 2020 – Jul 27, 2020 fscrypt: file system level encryption support

lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 fscrypt: restrict IV_INO_LBLK_* to AES-256-XTS

From: Eric Biggers <[email protected]>

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 b103fb7653ff ("fscrypt: add support for IV_INO_LBLK_64 policies")
Fixes e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
---
 fs/crypto/policy.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
fs/crypto/policy.c +14 -0
index 8a8ad0e44bb8..8e667aadf271 100644
@@ -77,6 +77,20 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
 	struct super_block *sb = inode->i_sb;
 	int ino_bits = 64, lblk_bits = 64;
 
+	/*
+	 * IV_INO_LBLK_* exist only because of hardware limitations, and
+	 * currently the only known use case for them involves AES-256-XTS.
+	 * That's also all we test currently.  For these reasons, for now only
+	 * allow AES-256-XTS here.  This can be relaxed later if a use case for
+	 * IV_INO_LBLK_* with other encryption modes arises.
+	 */
+	if (policy->contents_encryption_mode != FSCRYPT_MODE_AES_256_XTS) {
+		fscrypt_warn(inode,
+			     "Can't use %s policy with contents mode other than AES-256-XTS",
+			     type);
+		return false;
+	}
+
 	/*
 	 * It's unsafe to include inode numbers in the IVs if the filesystem can
 	 * potentially renumber inodes, e.g. via filesystem shrinking.
Signature · 1 line
2.27.0
author maintainer Applied
#1 lore raw
Quoted 38 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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 b103fb7653ff ("fscrypt: add support for IV_INO_LBLK_64 policies")
Fixes e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
---
 fs/crypto/policy.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
fs/crypto/policy.c +7 -0
index 8a8ad0e44bb8..8e667aadf271 100644
@@ -77,6 +77,20 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
 	struct super_block *sb = inode->i_sb;
 	int ino_bits = 64, lblk_bits = 64;
 
+	/*
+	 * IV_INO_LBLK_* exist only because of hardware limitations, and
+	 * currently the only known use case for them involves AES-256-XTS.
+	 * That's also all we test currently.  For these reasons, for now only
+	 * allow AES-256-XTS here.  This can be relaxed later if a use case for
+	 * IV_INO_LBLK_* with other encryption modes arises.
+	 */

fs/crypto/policy.c static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy, · line 96

Quoted 10 lines
fs/crypto/policy.c +7 -0
+	if (policy->contents_encryption_mode != FSCRYPT_MODE_AES_256_XTS) {
+		fscrypt_warn(inode,
+			     "Can't use %s policy with contents mode other than AES-256-XTS",
+			     type);
+		return false;
+	}
+
 	/*
 	 * It's unsafe to include inode numbers in the IVs if the filesystem can
 	 * potentially renumber inodes, e.g. via filesystem shrinking.

Applied to fscrypt.git#master for 5.9.

- Eric