]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
fscrypt: restrict IV_INO_LBLK_32 to ino_bits <= 32
authorEric Biggers <ebiggers@google.com>
Mon, 24 Aug 2020 20:38:41 +0000 (13:38 -0700)
committerEric Biggers <ebiggers@google.com>
Mon, 7 Sep 2020 22:27:42 +0000 (15:27 -0700)
commit5e895bd4d5233cb054447d0491d4e63c8496d419
treebc12486704ceb1cb7d7eb7b807fc33f54d180087
parent8b10fe68985278de4926daa56ad6af701839e40a
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: e3b1078bedd3 ("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>
fs/crypto/policy.c