fscrypt: add the test dummy encryption key on-demand
authorEric Biggers <ebiggers@google.com>
Wed, 8 Feb 2023 06:21:03 +0000 (22:21 -0800)
committerEric Biggers <ebiggers@google.com>
Wed, 8 Feb 2023 06:30:30 +0000 (22:30 -0800)
commit60e463f0be9874692a56a7d419a6e39029b6290d
tree0c8a86275f6b293eee0ad9081158311a07fe48ed
parent6d796c50f84ca79f1722bb131799e5a5710c4700
fscrypt: add the test dummy encryption key on-demand

When the key for an inode is not found but the inode is using the
test_dummy_encryption policy, automatically add the
test_dummy_encryption key to the filesystem keyring.  This eliminates
the need for all the individual filesystems to do this at mount time,
which is a bit tricky to clean up from on failure.

Note: this covers the call to fscrypt_find_master_key() from inode key
setup, but not from the fscrypt ioctls.  So, this isn't *exactly* the
same as the key being present from the very beginning.  I think we can
tolerate that, though, since the inode key setup caller is the only one
that actually matters in the context of test_dummy_encryption.

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