2019-05-19 14:07:45 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2012-05-11 11:56:56 +02:00
|
|
|
#
|
|
|
|
# Key management configuration
|
|
|
|
#
|
|
|
|
|
|
|
|
config KEYS
|
|
|
|
bool "Enable access key retention support"
|
2013-09-24 11:35:18 +02:00
|
|
|
select ASSOCIATIVE_ARRAY
|
2012-05-11 11:56:56 +02:00
|
|
|
help
|
|
|
|
This option provides support for retaining authentication tokens and
|
|
|
|
access keys in the kernel.
|
|
|
|
|
|
|
|
It also includes provision of methods by which such keys might be
|
|
|
|
associated with a process so that network filesystems, encryption
|
|
|
|
support and the like can find them.
|
|
|
|
|
|
|
|
Furthermore, a special type of key is available that acts as keyring:
|
|
|
|
a searchable sequence of keys. Each process is equipped with access
|
|
|
|
to five standard keyrings: UID-specific, GID-specific, session,
|
|
|
|
process and thread.
|
|
|
|
|
|
|
|
If you are unsure as to whether this is required, answer N.
|
|
|
|
|
2017-06-08 15:47:26 +02:00
|
|
|
config KEYS_COMPAT
|
|
|
|
def_bool y
|
|
|
|
depends on COMPAT && KEYS
|
|
|
|
|
keys: Cache result of request_key*() temporarily in task_struct
If a filesystem uses keys to hold authentication tokens, then it needs a
token for each VFS operation that might perform an authentication check -
either by passing it to the server, or using to perform a check based on
authentication data cached locally.
For open files this isn't a problem, since the key should be cached in the
file struct since it represents the subject performing operations on that
file descriptor.
During pathwalk, however, there isn't anywhere to cache the key, except
perhaps in the nameidata struct - but that isn't exposed to the
filesystems. Further, a pathwalk can incur a lot of operations, calling
one or more of the following, for instance:
->lookup()
->permission()
->d_revalidate()
->d_automount()
->get_acl()
->getxattr()
on each dentry/inode it encounters - and each one may need to call
request_key(). And then, at the end of pathwalk, it will call the actual
operation:
->mkdir()
->mknod()
->getattr()
->open()
...
which may need to go and get the token again.
However, it is very likely that all of the operations on a single
dentry/inode - and quite possibly a sequence of them - will all want to use
the same authentication token, which suggests that caching it would be a
good idea.
To this end:
(1) Make it so that a positive result of request_key() and co. that didn't
require upcalling to userspace is cached temporarily in task_struct.
(2) The cache is 1 deep, so a new result displaces the old one.
(3) The key is released by exit and by notify-resume.
(4) The cache is cleared in a newly forked process.
Signed-off-by: David Howells <dhowells@redhat.com>
2019-06-19 17:10:15 +02:00
|
|
|
config KEYS_REQUEST_CACHE
|
|
|
|
bool "Enable temporary caching of the last request_key() result"
|
|
|
|
depends on KEYS
|
|
|
|
help
|
|
|
|
This option causes the result of the last successful request_key()
|
|
|
|
call that didn't upcall to the kernel to be cached temporarily in the
|
|
|
|
task_struct. The cache is cleared by exit and just prior to the
|
|
|
|
resumption of userspace.
|
|
|
|
|
|
|
|
This allows the key used for multiple step processes where each step
|
|
|
|
wants to request a key that is likely the same as the one requested
|
|
|
|
by the last step to save on the searching.
|
|
|
|
|
|
|
|
An example of such a process is a pathwalk through a network
|
|
|
|
filesystem in which each method needs to request an authentication
|
|
|
|
key. Pathwalk will call multiple methods for each dentry traversed
|
|
|
|
(permission, d_revalidate, lookup, getxattr, getacl, ...).
|
|
|
|
|
2013-09-24 11:35:19 +02:00
|
|
|
config PERSISTENT_KEYRINGS
|
|
|
|
bool "Enable register of persistent per-UID keyrings"
|
|
|
|
depends on KEYS
|
|
|
|
help
|
|
|
|
This option provides a register of persistent per-UID keyrings,
|
|
|
|
primarily aimed at Kerberos key storage. The keyrings are persistent
|
|
|
|
in the sense that they stay around after all processes of that UID
|
|
|
|
have exited, not that they survive the machine being rebooted.
|
|
|
|
|
|
|
|
A particular keyring may be accessed by either the user whose keyring
|
|
|
|
it is or by a process with administrative privileges. The active
|
|
|
|
LSMs gets to rule on which admin-level processes get to access the
|
|
|
|
cache.
|
|
|
|
|
|
|
|
Keyrings are created and added into the register upon demand and get
|
|
|
|
removed if they expire (a default timeout is set upon creation).
|
|
|
|
|
2013-09-24 11:35:18 +02:00
|
|
|
config BIG_KEYS
|
2013-10-30 12:15:23 +01:00
|
|
|
bool "Large payload keys"
|
2013-09-24 11:35:18 +02:00
|
|
|
depends on KEYS
|
|
|
|
depends on TMPFS
|
2017-10-04 12:27:00 +02:00
|
|
|
select CRYPTO
|
2016-04-12 20:54:58 +02:00
|
|
|
select CRYPTO_AES
|
security/keys: rewrite all of big_key crypto
This started out as just replacing the use of crypto/rng with
get_random_bytes_wait, so that we wouldn't use bad randomness at boot
time. But, upon looking further, it appears that there were even deeper
underlying cryptographic problems, and that this seems to have been
committed with very little crypto review. So, I rewrote the whole thing,
trying to keep to the conventions introduced by the previous author, to
fix these cryptographic flaws.
It makes no sense to seed crypto/rng at boot time and then keep
using it like this, when in fact there's already get_random_bytes_wait,
which can ensure there's enough entropy and be a much more standard way
of generating keys. Since this sensitive material is being stored
untrusted, using ECB and no authentication is simply not okay at all. I
find it surprising and a bit horrifying that this code even made it past
basic crypto review, which perhaps points to some larger issues. This
patch moves from using AES-ECB to using AES-GCM. Since keys are uniquely
generated each time, we can set the nonce to zero. There was also a race
condition in which the same key would be reused at the same time in
different threads. A mutex fixes this issue now.
So, to summarize, this commit fixes the following vulnerabilities:
* Low entropy key generation, allowing an attacker to potentially
guess or predict keys.
* Unauthenticated encryption, allowing an attacker to modify the
cipher text in particular ways in order to manipulate the plaintext,
which is is even more frightening considering the next point.
* Use of ECB mode, allowing an attacker to trivially swap blocks or
compare identical plaintext blocks.
* Key re-use.
* Faulty memory zeroing.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Eric Biggers <ebiggers3@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: security@kernel.org
Cc: stable@vger.kernel.org
2017-09-20 16:58:39 +02:00
|
|
|
select CRYPTO_GCM
|
2013-09-24 11:35:18 +02:00
|
|
|
help
|
|
|
|
This option provides support for holding large keys within the kernel
|
|
|
|
(for example Kerberos ticket caches). The data may be stored out to
|
|
|
|
swapspace by tmpfs.
|
|
|
|
|
|
|
|
If you are unsure as to whether this is required, answer N.
|
|
|
|
|
2012-05-11 11:56:56 +02:00
|
|
|
config TRUSTED_KEYS
|
|
|
|
tristate "TRUSTED KEYS"
|
|
|
|
depends on KEYS && TCG_TPM
|
|
|
|
select CRYPTO
|
|
|
|
select CRYPTO_HMAC
|
|
|
|
select CRYPTO_SHA1
|
2015-11-05 20:43:06 +01:00
|
|
|
select CRYPTO_HASH_INFO
|
2012-05-11 11:56:56 +02:00
|
|
|
help
|
|
|
|
This option provides support for creating, sealing, and unsealing
|
|
|
|
keys in the kernel. Trusted keys are random number symmetric keys,
|
|
|
|
generated and RSA-sealed by the TPM. The TPM only unseals the keys,
|
|
|
|
if the boot PCRs and other criteria match. Userspace will only ever
|
|
|
|
see encrypted blobs.
|
|
|
|
|
|
|
|
If you are unsure as to whether this is required, answer N.
|
|
|
|
|
|
|
|
config ENCRYPTED_KEYS
|
|
|
|
tristate "ENCRYPTED KEYS"
|
|
|
|
depends on KEYS
|
|
|
|
select CRYPTO
|
|
|
|
select CRYPTO_HMAC
|
|
|
|
select CRYPTO_AES
|
|
|
|
select CRYPTO_CBC
|
|
|
|
select CRYPTO_SHA256
|
|
|
|
select CRYPTO_RNG
|
|
|
|
help
|
|
|
|
This option provides support for create/encrypting/decrypting keys
|
|
|
|
in the kernel. Encrypted keys are kernel generated random numbers,
|
|
|
|
which are encrypted/decrypted with a 'master' symmetric key. The
|
|
|
|
'master' key can be either a trusted-key or user-key type.
|
|
|
|
Userspace only ever sees/stores encrypted blobs.
|
|
|
|
|
|
|
|
If you are unsure as to whether this is required, answer N.
|
2016-04-12 20:54:58 +02:00
|
|
|
|
|
|
|
config KEY_DH_OPERATIONS
|
|
|
|
bool "Diffie-Hellman operations on retained keys"
|
|
|
|
depends on KEYS
|
2017-04-11 13:07:07 +02:00
|
|
|
select CRYPTO
|
2016-08-19 20:39:09 +02:00
|
|
|
select CRYPTO_HASH
|
2017-06-08 15:50:11 +02:00
|
|
|
select CRYPTO_DH
|
2016-04-12 20:54:58 +02:00
|
|
|
help
|
|
|
|
This option provides support for calculating Diffie-Hellman
|
|
|
|
public keys and shared secrets using values stored as keys
|
|
|
|
in the kernel.
|
|
|
|
|
|
|
|
If you are unsure as to whether this is required, answer N.
|