android_kernel_xiaomi_sm8350/fs/crypto
Eric Biggers fb4622ee74 UPSTREAM: fscrypt: fix derivation of SipHash keys on big endian CPUs
Typically, the cryptographic APIs that fscrypt uses take keys as byte
arrays, which avoids endianness issues.  However, siphash_key_t is an
exception.  It is defined as 'u64 key[2];', i.e. the 128-bit key is
expected to be given directly as two 64-bit words in CPU endianness.

fscrypt_derive_dirhash_key() and fscrypt_setup_iv_ino_lblk_32_key()
forgot to take this into account.  Therefore, the SipHash keys used to
index encrypted+casefolded directories differ on big endian vs. little
endian platforms, as do the SipHash keys used to hash inode numbers for
IV_INO_LBLK_32-encrypted directories.  This makes such directories
non-portable between these platforms.

Fix this by always using the little endian order.  This is a breaking
change for big endian platforms, but this should be fine in practice
since these features (encrypt+casefold support, and the IV_INO_LBLK_32
flag) aren't known to actually be used on any big endian platforms yet.

Bug: 254441685
Fixes: aa408f835d02 ("fscrypt: derive dirhash key for casefolded directories")
Fixes: e3b1078bedd3 ("fscrypt: add support for IV_INO_LBLK_32 policies")
Cc: <stable@vger.kernel.org> # v5.6+
Link: https://lore.kernel.org/r/20210605075033.54424-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit 2fc2b430f559fdf32d5d1dd5ceaa40e12fb77bdf)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I03555845a827b693fadaf1d61aa3977cd4ed9ecd
2022-11-22 07:58:42 +00:00
..
bio.c ANDROID: fscrypt: fix DUN contiguity with inline encryption + IV_INO_LBLK_32 policies 2020-07-14 15:48:10 +00:00
crypto.c BACKPORT: fscrypt: rename FS_KEY_DERIVATION_NONCE_SIZE 2022-11-22 07:58:42 +00:00
fname.c Merge 5.4.133 into android11-5.4-lts 2021-07-20 11:32:58 +02:00
fscrypt_private.h BACKPORT: fscrypt: rename FS_KEY_DERIVATION_NONCE_SIZE 2022-11-22 07:58:42 +00:00
hkdf.c
hooks.c This is the 5.4.145 stable release 2021-09-12 09:54:40 +02:00
inline_crypt.c UPSTREAM: fscrypt: use smp_load_acquire() for fscrypt_prepared_key 2020-11-14 16:29:43 +01:00
Kconfig
keyring.c This is the 5.4.87 stable release 2021-01-06 09:12:49 -08:00
keysetup_v1.c BACKPORT: fscrypt: rename FS_KEY_DERIVATION_NONCE_SIZE 2022-11-22 07:58:42 +00:00
keysetup.c UPSTREAM: fscrypt: fix derivation of SipHash keys on big endian CPUs 2022-11-22 07:58:42 +00:00
Makefile
policy.c BACKPORT: fscrypt: rename FS_KEY_DERIVATION_NONCE_SIZE 2022-11-22 07:58:42 +00:00