kernel_optimize_test/fs/crypto
Eric Biggers 5e895bd4d5 fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
When an encryption policy has the IV_INO_LBLK_32 flag set, the IV
generation method involves hashing the inode number.  This is different
from fscrypt's other IV generation methods, where the inode number is
either not used at all or is included directly in the IVs.

Therefore, in principle IV_INO_LBLK_32 can work with any length inode
number.  However, currently fscrypt gets the inode number from
inode::i_ino, which is 'unsigned long'.  So currently the implementation
limit is actually 32 bits (like IV_INO_LBLK_64), since longer inode
numbers will have been truncated by the VFS on 32-bit platforms.

Fix fscrypt_supported_v2_policy() to enforce the correct limit.

This doesn't actually matter currently, since only ext4 and f2fs support
IV_INO_LBLK_32, and they both only support 32-bit inode numbers.  But we
might as well fix it in case it matters in the future.

Ideally inode::i_ino would instead be made 64-bit, but for now it's not
needed.  (Note, this limit does *not* prevent filesystems with 64-bit
inode numbers from adding fscrypt support, since IV_INO_LBLK_* support
is optional and is useful only on certain hardware.)

Fixes: e3b1078bed ("fscrypt: add support for IV_INO_LBLK_32 policies")
Reported-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20200824203841.1707847-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-09-07 15:27:42 -07:00
..
bio.c fscrypt: add inline encryption support 2020-07-08 10:29:30 -07:00
crypto.c fscrypt: rename FS_KEY_DERIVATION_NONCE_SIZE 2020-07-20 17:26:33 -07:00
fname.c fscrypt: drop unused inode argument from fscrypt_fname_alloc_buffer 2020-09-07 15:27:42 -07:00
fscrypt_private.h fscrypt: use smp_load_acquire() for fscrypt_prepared_key 2020-07-21 16:02:13 -07:00
hkdf.c fscrypt: use crypto_shash_tfm_digest() 2020-05-08 15:32:14 +10:00
hooks.c fscrypt: drop unused inode argument from fscrypt_fname_alloc_buffer 2020-09-07 15:27:42 -07:00
inline_crypt.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
Kconfig fscrypt: switch fscrypt_do_sha256() to use the SHA-256 library 2020-07-21 16:02:13 -07:00
keyring.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
keysetup_v1.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
keysetup.c fscrypt: use smp_load_acquire() for ->i_crypt_info 2020-07-21 16:02:13 -07:00
Makefile fscrypt: add inline encryption support 2020-07-08 10:29:30 -07:00
policy.c fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32 2020-09-07 15:27:42 -07:00