2019-05-19 20:07:45 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2012-05-11 17:56:56 +08:00
|
|
|
#
|
|
|
|
# Key management configuration
|
|
|
|
#
|
|
|
|
|
|
|
|
config KEYS
|
|
|
|
bool "Enable access key retention support"
|
2013-09-24 17:35:18 +08:00
|
|
|
select ASSOCIATIVE_ARRAY
|
2012-05-11 17:56:56 +08: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.
|
|
|
|
|
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 23:10:15 +08: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 17:35:19 +08: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 17:35:18 +08:00
|
|
|
config BIG_KEYS
|
2013-10-30 19:15:23 +08:00
|
|
|
bool "Large payload keys"
|
2013-09-24 17:35:18 +08:00
|
|
|
depends on KEYS
|
|
|
|
depends on TMPFS
|
2020-05-12 05:51:01 +08:00
|
|
|
depends on CRYPTO_LIB_CHACHA20POLY1305 = y
|
2013-09-24 17:35:18 +08: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 17:56:56 +08:00
|
|
|
config TRUSTED_KEYS
|
|
|
|
tristate "TRUSTED KEYS"
|
|
|
|
depends on KEYS && TCG_TPM
|
|
|
|
select CRYPTO
|
|
|
|
select CRYPTO_HMAC
|
|
|
|
select CRYPTO_SHA1
|
2015-11-06 03:43:06 +08:00
|
|
|
select CRYPTO_HASH_INFO
|
2012-05-11 17:56:56 +08: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-13 02:54:58 +08:00
|
|
|
|
|
|
|
config KEY_DH_OPERATIONS
|
|
|
|
bool "Diffie-Hellman operations on retained keys"
|
|
|
|
depends on KEYS
|
2017-04-11 19:07:07 +08:00
|
|
|
select CRYPTO
|
2016-08-20 02:39:09 +08:00
|
|
|
select CRYPTO_HASH
|
2017-06-08 21:50:11 +08:00
|
|
|
select CRYPTO_DH
|
2016-04-13 02:54:58 +08: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.
|
watch_queue: Add a key/keyring notification facility
Add a key/keyring change notification facility whereby notifications about
changes in key and keyring content and attributes can be received.
Firstly, an event queue needs to be created:
pipe2(fds, O_NOTIFICATION_PIPE);
ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, 256);
then a notification can be set up to report notifications via that queue:
struct watch_notification_filter filter = {
.nr_filters = 1,
.filters = {
[0] = {
.type = WATCH_TYPE_KEY_NOTIFY,
.subtype_filter[0] = UINT_MAX,
},
},
};
ioctl(fds[1], IOC_WATCH_QUEUE_SET_FILTER, &filter);
keyctl_watch_key(KEY_SPEC_SESSION_KEYRING, fds[1], 0x01);
After that, records will be placed into the queue when events occur in
which keys are changed in some way. Records are of the following format:
struct key_notification {
struct watch_notification watch;
__u32 key_id;
__u32 aux;
} *n;
Where:
n->watch.type will be WATCH_TYPE_KEY_NOTIFY.
n->watch.subtype will indicate the type of event, such as
NOTIFY_KEY_REVOKED.
n->watch.info & WATCH_INFO_LENGTH will indicate the length of the
record.
n->watch.info & WATCH_INFO_ID will be the second argument to
keyctl_watch_key(), shifted.
n->key will be the ID of the affected key.
n->aux will hold subtype-dependent information, such as the key
being linked into the keyring specified by n->key in the case of
NOTIFY_KEY_LINKED.
Note that it is permissible for event records to be of variable length -
or, at least, the length may be dependent on the subtype. Note also that
the queue can be shared between multiple notifications of various types.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <jamorris@linux.microsoft.com>
2020-01-15 01:07:11 +08:00
|
|
|
|
|
|
|
config KEY_NOTIFICATIONS
|
|
|
|
bool "Provide key/keyring change notifications"
|
|
|
|
depends on KEYS && WATCH_QUEUE
|
|
|
|
help
|
2020-11-25 04:28:02 +08:00
|
|
|
This option provides support for getting change notifications
|
|
|
|
on keys and keyrings on which the caller has View permission.
|
|
|
|
This makes use of pipes to handle the notification buffer and
|
|
|
|
provides KEYCTL_WATCH_KEY to enable/disable watches.
|