]> git.baikalelectronics.ru Git - kernel.git/commit
fscrypt: check for appropriate use of DIRECT_KEY flag earlier
authorEric Biggers <ebiggers@google.com>
Mon, 9 Dec 2019 21:18:27 +0000 (13:18 -0800)
committerEric Biggers <ebiggers@google.com>
Tue, 31 Dec 2019 16:33:50 +0000 (10:33 -0600)
commita12ef40d7371fce198344f55c075c19a634477a0
tree5082ec8d9d7090a45e40c5a4808b46ac9d8c096b
parent6b1ed202199bf645195154486fdc91ea9635af83
fscrypt: check for appropriate use of DIRECT_KEY flag earlier

FSCRYPT_POLICY_FLAG_DIRECT_KEY is currently only allowed with Adiantum
encryption.  But FS_IOC_SET_ENCRYPTION_POLICY allowed it in combination
with other encryption modes, and an error wasn't reported until later
when the encrypted directory was actually used.

Fix it to report the error earlier by validating the correct use of the
DIRECT_KEY flag in fscrypt_supported_policy(), similar to how we
validate the IV_INO_LBLK_64 flag.

Link: https://lore.kernel.org/r/20191209211829.239800-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/fscrypt_private.h
fs/crypto/keysetup.c
fs/crypto/keysetup_v1.c
fs/crypto/policy.c