2007-10-17 10:29:46 +04:00
|
|
|
/* Authentication token and access key management
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2007-10-17 10:29:46 +04:00
|
|
|
* Copyright (C) 2004, 2007 Red Hat, Inc. All Rights Reserved.
|
2005-04-17 02:20:36 +04:00
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
*
|
2017-05-13 14:51:50 +03:00
|
|
|
* See Documentation/security/keys/core.rst for information on keys/keyrings.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_KEY_H
|
|
|
|
#define _LINUX_KEY_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rbtree.h>
|
2005-06-24 09:00:49 +04:00
|
|
|
#include <linux/rcupdate.h>
|
2008-04-29 12:01:32 +04:00
|
|
|
#include <linux/sysctl.h>
|
2009-03-24 11:54:46 +03:00
|
|
|
#include <linux/rwsem.h>
|
2011-07-27 03:09:06 +04:00
|
|
|
#include <linux/atomic.h>
|
2013-09-24 13:35:18 +04:00
|
|
|
#include <linux/assoc_array.h>
|
2017-03-31 15:20:48 +03:00
|
|
|
#include <linux/refcount.h>
|
2017-11-15 19:38:45 +03:00
|
|
|
#include <linux/time64.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
2012-02-08 19:53:04 +04:00
|
|
|
#include <linux/uidgid.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* key handle serial number */
|
|
|
|
typedef int32_t key_serial_t;
|
|
|
|
|
|
|
|
/* key handle permissions mask */
|
|
|
|
typedef uint32_t key_perm_t;
|
|
|
|
|
|
|
|
struct key;
|
|
|
|
|
|
|
|
#ifdef CONFIG_KEYS
|
|
|
|
|
|
|
|
#undef KEY_DEBUGGING
|
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
#define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */
|
|
|
|
#define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */
|
|
|
|
#define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */
|
|
|
|
#define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */
|
|
|
|
#define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */
|
2005-10-31 02:02:44 +03:00
|
|
|
#define KEY_POS_SETATTR 0x20000000 /* possessor can set key attributes */
|
|
|
|
#define KEY_POS_ALL 0x3f000000
|
2005-09-28 20:03:15 +04:00
|
|
|
|
|
|
|
#define KEY_USR_VIEW 0x00010000 /* user permissions... */
|
|
|
|
#define KEY_USR_READ 0x00020000
|
|
|
|
#define KEY_USR_WRITE 0x00040000
|
|
|
|
#define KEY_USR_SEARCH 0x00080000
|
|
|
|
#define KEY_USR_LINK 0x00100000
|
2005-10-31 02:02:44 +03:00
|
|
|
#define KEY_USR_SETATTR 0x00200000
|
|
|
|
#define KEY_USR_ALL 0x003f0000
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define KEY_GRP_VIEW 0x00000100 /* group permissions... */
|
|
|
|
#define KEY_GRP_READ 0x00000200
|
|
|
|
#define KEY_GRP_WRITE 0x00000400
|
|
|
|
#define KEY_GRP_SEARCH 0x00000800
|
|
|
|
#define KEY_GRP_LINK 0x00001000
|
2005-10-31 02:02:44 +03:00
|
|
|
#define KEY_GRP_SETATTR 0x00002000
|
|
|
|
#define KEY_GRP_ALL 0x00003f00
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#define KEY_OTH_VIEW 0x00000001 /* third party permissions... */
|
|
|
|
#define KEY_OTH_READ 0x00000002
|
|
|
|
#define KEY_OTH_WRITE 0x00000004
|
|
|
|
#define KEY_OTH_SEARCH 0x00000008
|
|
|
|
#define KEY_OTH_LINK 0x00000010
|
2005-10-31 02:02:44 +03:00
|
|
|
#define KEY_OTH_SETATTR 0x00000020
|
|
|
|
#define KEY_OTH_ALL 0x0000003f
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-04-29 12:01:28 +04:00
|
|
|
#define KEY_PERM_UNDEF 0xffffffff
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
struct seq_file;
|
|
|
|
struct user_struct;
|
|
|
|
struct signal_struct;
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-14 02:39:23 +03:00
|
|
|
struct cred;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct key_type;
|
|
|
|
struct key_owner;
|
|
|
|
struct keyring_list;
|
|
|
|
struct keyring_name;
|
|
|
|
|
2013-09-24 13:35:15 +04:00
|
|
|
struct keyring_index_key {
|
|
|
|
struct key_type *type;
|
|
|
|
const char *description;
|
|
|
|
size_t desc_len;
|
|
|
|
};
|
|
|
|
|
2015-10-21 16:04:48 +03:00
|
|
|
union key_payload {
|
|
|
|
void __rcu *rcu_data0;
|
|
|
|
void *data[4];
|
|
|
|
};
|
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* key reference with possession attribute handling
|
|
|
|
*
|
|
|
|
* NOTE! key_ref_t is a typedef'd pointer to a type that is not actually
|
|
|
|
* defined. This is because we abuse the bottom bit of the reference to carry a
|
|
|
|
* flag to indicate whether the calling process possesses that key in one of
|
|
|
|
* its keyrings.
|
|
|
|
*
|
|
|
|
* the key_ref_t has been made a separate type so that the compiler can reject
|
|
|
|
* attempts to dereference it without proper conversion.
|
|
|
|
*
|
|
|
|
* the three functions are used to assemble and disassemble references
|
|
|
|
*/
|
|
|
|
typedef struct __key_reference_with_attributes *key_ref_t;
|
|
|
|
|
|
|
|
static inline key_ref_t make_key_ref(const struct key *key,
|
2013-09-24 13:35:14 +04:00
|
|
|
bool possession)
|
2005-09-28 20:03:15 +04:00
|
|
|
{
|
|
|
|
return (key_ref_t) ((unsigned long) key | possession);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct key *key_ref_to_ptr(const key_ref_t key_ref)
|
|
|
|
{
|
|
|
|
return (struct key *) ((unsigned long) key_ref & ~1UL);
|
|
|
|
}
|
|
|
|
|
2013-09-24 13:35:14 +04:00
|
|
|
static inline bool is_key_possessed(const key_ref_t key_ref)
|
2005-09-28 20:03:15 +04:00
|
|
|
{
|
|
|
|
return (unsigned long) key_ref & 1UL;
|
|
|
|
}
|
|
|
|
|
2016-08-30 21:33:13 +03:00
|
|
|
typedef int (*key_restrict_link_func_t)(struct key *dest_keyring,
|
2016-04-25 21:30:39 +03:00
|
|
|
const struct key_type *type,
|
2016-08-30 21:33:13 +03:00
|
|
|
const union key_payload *payload,
|
|
|
|
struct key *restriction_key);
|
2016-04-25 21:30:39 +03:00
|
|
|
|
2016-06-28 02:10:59 +03:00
|
|
|
struct key_restriction {
|
|
|
|
key_restrict_link_func_t check;
|
|
|
|
struct key *key;
|
|
|
|
struct key_type *keytype;
|
|
|
|
};
|
|
|
|
|
2017-10-04 18:43:25 +03:00
|
|
|
enum key_state {
|
|
|
|
KEY_IS_UNINSTANTIATED,
|
|
|
|
KEY_IS_POSITIVE, /* Positively instantiated */
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* authentication token / access credential / keyring
|
|
|
|
* - types of key include:
|
|
|
|
* - keyrings
|
|
|
|
* - disk encryption IDs
|
|
|
|
* - Kerberos TGTs and tickets
|
|
|
|
*/
|
|
|
|
struct key {
|
2017-03-31 15:20:48 +03:00
|
|
|
refcount_t usage; /* number of references */
|
2005-04-17 02:20:36 +04:00
|
|
|
key_serial_t serial; /* key serial number */
|
2012-05-11 13:56:56 +04:00
|
|
|
union {
|
|
|
|
struct list_head graveyard_link;
|
|
|
|
struct rb_node serial_node;
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
struct rw_semaphore sem; /* change vs change sem */
|
|
|
|
struct key_user *user; /* owner of this key */
|
2005-10-31 02:02:44 +03:00
|
|
|
void *security; /* security data for this key */
|
2009-09-02 12:14:00 +04:00
|
|
|
union {
|
2017-11-15 19:38:45 +03:00
|
|
|
time64_t expiry; /* time at which key expires (or 0) */
|
|
|
|
time64_t revoked_at; /* time at which key was revoked */
|
2009-09-02 12:14:00 +04:00
|
|
|
};
|
2017-11-15 19:38:45 +03:00
|
|
|
time64_t last_used_at; /* last time used for LRU keyring discard */
|
2012-02-08 19:53:04 +04:00
|
|
|
kuid_t uid;
|
|
|
|
kgid_t gid;
|
2005-04-17 02:20:36 +04:00
|
|
|
key_perm_t perm; /* access permissions */
|
|
|
|
unsigned short quotalen; /* length added to quota */
|
2005-06-24 09:00:49 +04:00
|
|
|
unsigned short datalen; /* payload data length
|
|
|
|
* - may not match RCU dereferenced payload
|
|
|
|
* - payload should contain own length
|
|
|
|
*/
|
2017-10-04 18:43:25 +03:00
|
|
|
short state; /* Key state (+) or rejection error (-) */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#ifdef KEY_DEBUGGING
|
|
|
|
unsigned magic;
|
|
|
|
#define KEY_DEBUG_MAGIC 0x18273645u
|
|
|
|
#endif
|
|
|
|
|
2005-06-24 09:00:49 +04:00
|
|
|
unsigned long flags; /* status flags (change with bitops) */
|
2017-10-04 18:43:25 +03:00
|
|
|
#define KEY_FLAG_DEAD 0 /* set if key type has been deleted */
|
|
|
|
#define KEY_FLAG_REVOKED 1 /* set if key had been revoked */
|
|
|
|
#define KEY_FLAG_IN_QUOTA 2 /* set if key consumes quota */
|
|
|
|
#define KEY_FLAG_USER_CONSTRUCT 3 /* set if key is being constructed in userspace */
|
|
|
|
#define KEY_FLAG_ROOT_CAN_CLEAR 4 /* set if key can be cleared by root without permission */
|
|
|
|
#define KEY_FLAG_INVALIDATED 5 /* set if key has been invalidated */
|
|
|
|
#define KEY_FLAG_BUILTIN 6 /* set if key is built in to the kernel */
|
|
|
|
#define KEY_FLAG_ROOT_CAN_INVAL 7 /* set if key can be invalidated by root without permission */
|
|
|
|
#define KEY_FLAG_KEEP 8 /* set if key should not be removed */
|
|
|
|
#define KEY_FLAG_UID_KEYRING 9 /* set if key is a user or user session keyring */
|
2005-06-24 09:00:49 +04:00
|
|
|
|
2013-09-24 13:35:15 +04:00
|
|
|
/* the key type and key description string
|
|
|
|
* - the desc is used to match a key against search criteria
|
|
|
|
* - it should be a printable string
|
2005-04-17 02:20:36 +04:00
|
|
|
* - eg: for krb5 AFS, this might be "afs@REDHAT.COM"
|
|
|
|
*/
|
2013-09-24 13:35:15 +04:00
|
|
|
union {
|
|
|
|
struct keyring_index_key index_key;
|
|
|
|
struct {
|
|
|
|
struct key_type *type; /* type of key */
|
|
|
|
char *description;
|
|
|
|
};
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* key data
|
|
|
|
* - this is used to hold the data actually used in cryptography or
|
|
|
|
* whatever
|
|
|
|
*/
|
|
|
|
union {
|
2015-10-21 16:04:48 +03:00
|
|
|
union key_payload payload;
|
|
|
|
struct {
|
|
|
|
/* Keyring bits */
|
|
|
|
struct list_head name_link;
|
|
|
|
struct assoc_array keys;
|
|
|
|
};
|
2013-09-24 13:35:18 +04:00
|
|
|
};
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
|
|
|
|
/* This is set on a keyring to restrict the addition of a link to a key
|
2016-09-01 02:05:43 +03:00
|
|
|
* to it. If this structure isn't provided then it is assumed that the
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
* keyring is open to any addition. It is ignored for non-keyring
|
2017-03-02 03:44:09 +03:00
|
|
|
* keys. Only set this value using keyring_restrict(), keyring_alloc(),
|
|
|
|
* or key_alloc().
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
*
|
|
|
|
* This is intended for use with rings of trusted keys whereby addition
|
|
|
|
* to the keyring needs to be controlled. KEY_ALLOC_BYPASS_RESTRICTION
|
|
|
|
* overrides this, allowing the kernel to add extra keys without
|
|
|
|
* restriction.
|
|
|
|
*/
|
2016-09-01 02:05:43 +03:00
|
|
|
struct key_restriction *restrict_link;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct key *key_alloc(struct key_type *type,
|
|
|
|
const char *desc,
|
2012-02-08 19:53:04 +04:00
|
|
|
kuid_t uid, kgid_t gid,
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-14 02:39:23 +03:00
|
|
|
const struct cred *cred,
|
2006-06-26 11:24:50 +04:00
|
|
|
key_perm_t perm,
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
unsigned long flags,
|
2016-09-01 02:05:43 +03:00
|
|
|
struct key_restriction *restrict_link);
|
2006-06-26 11:24:50 +04:00
|
|
|
|
|
|
|
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
#define KEY_ALLOC_IN_QUOTA 0x0000 /* add to quota, reject if would overrun */
|
|
|
|
#define KEY_ALLOC_QUOTA_OVERRUN 0x0001 /* add to quota, permit even if overrun */
|
|
|
|
#define KEY_ALLOC_NOT_IN_QUOTA 0x0002 /* not in quota */
|
2016-04-06 18:14:26 +03:00
|
|
|
#define KEY_ALLOC_BUILT_IN 0x0004 /* Key is built into kernel */
|
|
|
|
#define KEY_ALLOC_BYPASS_RESTRICTION 0x0008 /* Override the check on restricted keyrings */
|
2017-09-18 21:37:03 +03:00
|
|
|
#define KEY_ALLOC_UID_KEYRING 0x0010 /* allocating a user or user session keyring */
|
2006-06-26 11:24:50 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void key_revoke(struct key *key);
|
2012-05-11 13:56:56 +04:00
|
|
|
extern void key_invalidate(struct key *key);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void key_put(struct key *key);
|
|
|
|
|
2013-09-24 13:35:16 +04:00
|
|
|
static inline struct key *__key_get(struct key *key)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2017-03-31 15:20:48 +03:00
|
|
|
refcount_inc(&key->usage);
|
2005-04-17 02:20:36 +04:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2013-09-24 13:35:16 +04:00
|
|
|
static inline struct key *key_get(struct key *key)
|
|
|
|
{
|
|
|
|
return key ? __key_get(key) : key;
|
|
|
|
}
|
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
static inline void key_ref_put(key_ref_t key_ref)
|
|
|
|
{
|
|
|
|
key_put(key_ref_to_ptr(key_ref));
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct key *request_key(struct key_type *type,
|
|
|
|
const char *description,
|
|
|
|
const char *callout_info);
|
|
|
|
|
2019-06-19 18:10:15 +03:00
|
|
|
extern struct key *request_key_rcu(struct key_type *type,
|
|
|
|
const char *description);
|
|
|
|
|
2006-06-29 13:24:28 +04:00
|
|
|
extern struct key *request_key_with_auxdata(struct key_type *type,
|
|
|
|
const char *description,
|
2008-04-29 12:01:24 +04:00
|
|
|
const void *callout_info,
|
|
|
|
size_t callout_len,
|
2006-06-29 13:24:28 +04:00
|
|
|
void *aux);
|
2007-10-17 10:29:46 +04:00
|
|
|
|
|
|
|
extern int wait_for_key_construction(struct key *key, bool intr);
|
|
|
|
|
2012-05-15 17:11:11 +04:00
|
|
|
extern int key_validate(const struct key *key);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
extern key_ref_t key_create_or_update(key_ref_t keyring,
|
|
|
|
const char *type,
|
|
|
|
const char *description,
|
|
|
|
const void *payload,
|
|
|
|
size_t plen,
|
2008-04-29 12:01:28 +04:00
|
|
|
key_perm_t perm,
|
2006-06-26 11:24:50 +04:00
|
|
|
unsigned long flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
extern int key_update(key_ref_t key,
|
2005-04-17 02:20:36 +04:00
|
|
|
const void *payload,
|
|
|
|
size_t plen);
|
|
|
|
|
|
|
|
extern int key_link(struct key *keyring,
|
|
|
|
struct key *key);
|
|
|
|
|
2019-05-20 23:51:50 +03:00
|
|
|
extern int key_move(struct key *key,
|
|
|
|
struct key *from_keyring,
|
|
|
|
struct key *to_keyring,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int key_unlink(struct key *keyring,
|
|
|
|
struct key *key);
|
|
|
|
|
2012-02-08 19:53:04 +04:00
|
|
|
extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-14 02:39:23 +03:00
|
|
|
const struct cred *cred,
|
2012-10-02 22:24:56 +04:00
|
|
|
key_perm_t perm,
|
2006-06-26 11:24:50 +04:00
|
|
|
unsigned long flags,
|
2016-09-01 02:05:43 +03:00
|
|
|
struct key_restriction *restrict_link,
|
2006-06-23 01:47:17 +04:00
|
|
|
struct key *dest);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
extern int restrict_link_reject(struct key *keyring,
|
|
|
|
const struct key_type *type,
|
2016-08-30 21:33:13 +03:00
|
|
|
const union key_payload *payload,
|
|
|
|
struct key *restriction_key);
|
KEYS: Add a facility to restrict new links into a keyring
Add a facility whereby proposed new links to be added to a keyring can be
vetted, permitting them to be rejected if necessary. This can be used to
block public keys from which the signature cannot be verified or for which
the signature verification fails. It could also be used to provide
blacklisting.
This affects operations like add_key(), KEYCTL_LINK and KEYCTL_INSTANTIATE.
To this end:
(1) A function pointer is added to the key struct that, if set, points to
the vetting function. This is called as:
int (*restrict_link)(struct key *keyring,
const struct key_type *key_type,
unsigned long key_flags,
const union key_payload *key_payload),
where 'keyring' will be the keyring being added to, key_type and
key_payload will describe the key being added and key_flags[*] can be
AND'ed with KEY_FLAG_TRUSTED.
[*] This parameter will be removed in a later patch when
KEY_FLAG_TRUSTED is removed.
The function should return 0 to allow the link to take place or an
error (typically -ENOKEY, -ENOPKG or -EKEYREJECTED) to reject the
link.
The pointer should not be set directly, but rather should be set
through keyring_alloc().
Note that if called during add_key(), preparse is called before this
method, but a key isn't actually allocated until after this function
is called.
(2) KEY_ALLOC_BYPASS_RESTRICTION is added. This can be passed to
key_create_or_update() or key_instantiate_and_link() to bypass the
restriction check.
(3) KEY_FLAG_TRUSTED_ONLY is removed. The entire contents of a keyring
with this restriction emplaced can be considered 'trustworthy' by
virtue of being in the keyring when that keyring is consulted.
(4) key_alloc() and keyring_alloc() take an extra argument that will be
used to set restrict_link in the new key. This ensures that the
pointer is set before the key is published, thus preventing a window
of unrestrictedness. Normally this argument will be NULL.
(5) As a temporary affair, keyring_restrict_trusted_only() is added. It
should be passed to keyring_alloc() as the extra argument instead of
setting KEY_FLAG_TRUSTED_ONLY on a keyring. This will be replaced in
a later patch with functions that look in the appropriate places for
authoritative keys.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
2016-04-06 18:14:24 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int keyring_clear(struct key *keyring);
|
|
|
|
|
2005-09-28 20:03:15 +04:00
|
|
|
extern key_ref_t keyring_search(key_ref_t keyring,
|
|
|
|
struct key_type *type,
|
|
|
|
const char *description);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
extern int keyring_add_key(struct key *keyring,
|
|
|
|
struct key *key);
|
|
|
|
|
2017-03-02 03:44:09 +03:00
|
|
|
extern int keyring_restrict(key_ref_t keyring, const char *type,
|
|
|
|
const char *restriction);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
extern struct key *key_lookup(key_serial_t id);
|
|
|
|
|
2012-01-18 14:04:29 +04:00
|
|
|
static inline key_serial_t key_serial(const struct key *key)
|
2008-04-29 12:01:34 +04:00
|
|
|
{
|
|
|
|
return key ? key->serial : 0;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-24 23:14:50 +04:00
|
|
|
extern void key_set_timeout(struct key *, unsigned);
|
|
|
|
|
2018-12-04 21:31:27 +03:00
|
|
|
extern key_ref_t lookup_user_key(key_serial_t id, unsigned long flags,
|
|
|
|
key_perm_t perm);
|
|
|
|
|
2014-03-14 21:44:49 +04:00
|
|
|
/*
|
|
|
|
* The permissions required on a key that we're looking up.
|
|
|
|
*/
|
|
|
|
#define KEY_NEED_VIEW 0x01 /* Require permission to view attributes */
|
|
|
|
#define KEY_NEED_READ 0x02 /* Require permission to read content */
|
|
|
|
#define KEY_NEED_WRITE 0x04 /* Require permission to update / modify */
|
|
|
|
#define KEY_NEED_SEARCH 0x08 /* Require permission to search (keyring) or find (key) */
|
|
|
|
#define KEY_NEED_LINK 0x10 /* Require permission to link */
|
|
|
|
#define KEY_NEED_SETATTR 0x20 /* Require permission to change attributes */
|
|
|
|
#define KEY_NEED_ALL 0x3f /* All the above permissions */
|
|
|
|
|
2017-10-04 18:43:25 +03:00
|
|
|
static inline short key_read_state(const struct key *key)
|
|
|
|
{
|
|
|
|
/* Barrier versus mark_key_instantiated(). */
|
|
|
|
return smp_load_acquire(&key->state);
|
|
|
|
}
|
|
|
|
|
2011-03-11 20:57:23 +03:00
|
|
|
/**
|
2017-10-04 18:43:25 +03:00
|
|
|
* key_is_positive - Determine if a key has been positively instantiated
|
2011-03-11 20:57:23 +03:00
|
|
|
* @key: The key to check.
|
|
|
|
*
|
|
|
|
* Return true if the specified key has been positively instantiated, false
|
|
|
|
* otherwise.
|
|
|
|
*/
|
2017-10-04 18:43:25 +03:00
|
|
|
static inline bool key_is_positive(const struct key *key)
|
|
|
|
{
|
|
|
|
return key_read_state(key) == KEY_IS_POSITIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool key_is_negative(const struct key *key)
|
2011-03-11 20:57:23 +03:00
|
|
|
{
|
2017-10-04 18:43:25 +03:00
|
|
|
return key_read_state(key) < 0;
|
2011-03-11 20:57:23 +03:00
|
|
|
}
|
|
|
|
|
2017-03-01 18:11:23 +03:00
|
|
|
#define dereference_key_rcu(KEY) \
|
|
|
|
(rcu_dereference((KEY)->payload.rcu_data0))
|
|
|
|
|
|
|
|
#define dereference_key_locked(KEY) \
|
2015-10-21 16:04:48 +03:00
|
|
|
(rcu_dereference_protected((KEY)->payload.rcu_data0, \
|
2011-03-07 18:05:51 +03:00
|
|
|
rwsem_is_locked(&((struct key *)(KEY))->sem)))
|
|
|
|
|
2012-01-18 00:39:51 +04:00
|
|
|
#define rcu_assign_keypointer(KEY, PAYLOAD) \
|
2012-05-17 03:31:38 +04:00
|
|
|
do { \
|
2015-10-21 16:04:48 +03:00
|
|
|
rcu_assign_pointer((KEY)->payload.rcu_data0, (PAYLOAD)); \
|
2012-05-17 03:31:38 +04:00
|
|
|
} while (0)
|
2012-01-18 00:39:51 +04:00
|
|
|
|
2008-04-29 12:01:32 +04:00
|
|
|
#ifdef CONFIG_SYSCTL
|
2014-06-07 01:38:06 +04:00
|
|
|
extern struct ctl_table key_sysctls[];
|
2008-04-29 12:01:32 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* the userspace interface
|
|
|
|
*/
|
CRED: Inaugurate COW credentials
Inaugurate copy-on-write credentials management. This uses RCU to manage the
credentials pointer in the task_struct with respect to accesses by other tasks.
A process may only modify its own credentials, and so does not need locking to
access or modify its own credentials.
A mutex (cred_replace_mutex) is added to the task_struct to control the effect
of PTRACE_ATTACHED on credential calculations, particularly with respect to
execve().
With this patch, the contents of an active credentials struct may not be
changed directly; rather a new set of credentials must be prepared, modified
and committed using something like the following sequence of events:
struct cred *new = prepare_creds();
int ret = blah(new);
if (ret < 0) {
abort_creds(new);
return ret;
}
return commit_creds(new);
There are some exceptions to this rule: the keyrings pointed to by the active
credentials may be instantiated - keyrings violate the COW rule as managing
COW keyrings is tricky, given that it is possible for a task to directly alter
the keys in a keyring in use by another task.
To help enforce this, various pointers to sets of credentials, such as those in
the task_struct, are declared const. The purpose of this is compile-time
discouragement of altering credentials through those pointers. Once a set of
credentials has been made public through one of these pointers, it may not be
modified, except under special circumstances:
(1) Its reference count may incremented and decremented.
(2) The keyrings to which it points may be modified, but not replaced.
The only safe way to modify anything else is to create a replacement and commit
using the functions described in Documentation/credentials.txt (which will be
added by a later patch).
This patch and the preceding patches have been tested with the LTP SELinux
testsuite.
This patch makes several logical sets of alteration:
(1) execve().
This now prepares and commits credentials in various places in the
security code rather than altering the current creds directly.
(2) Temporary credential overrides.
do_coredump() and sys_faccessat() now prepare their own credentials and
temporarily override the ones currently on the acting thread, whilst
preventing interference from other threads by holding cred_replace_mutex
on the thread being dumped.
This will be replaced in a future patch by something that hands down the
credentials directly to the functions being called, rather than altering
the task's objective credentials.
(3) LSM interface.
A number of functions have been changed, added or removed:
(*) security_capset_check(), ->capset_check()
(*) security_capset_set(), ->capset_set()
Removed in favour of security_capset().
(*) security_capset(), ->capset()
New. This is passed a pointer to the new creds, a pointer to the old
creds and the proposed capability sets. It should fill in the new
creds or return an error. All pointers, barring the pointer to the
new creds, are now const.
(*) security_bprm_apply_creds(), ->bprm_apply_creds()
Changed; now returns a value, which will cause the process to be
killed if it's an error.
(*) security_task_alloc(), ->task_alloc_security()
Removed in favour of security_prepare_creds().
(*) security_cred_free(), ->cred_free()
New. Free security data attached to cred->security.
(*) security_prepare_creds(), ->cred_prepare()
New. Duplicate any security data attached to cred->security.
(*) security_commit_creds(), ->cred_commit()
New. Apply any security effects for the upcoming installation of new
security by commit_creds().
(*) security_task_post_setuid(), ->task_post_setuid()
Removed in favour of security_task_fix_setuid().
(*) security_task_fix_setuid(), ->task_fix_setuid()
Fix up the proposed new credentials for setuid(). This is used by
cap_set_fix_setuid() to implicitly adjust capabilities in line with
setuid() changes. Changes are made to the new credentials, rather
than the task itself as in security_task_post_setuid().
(*) security_task_reparent_to_init(), ->task_reparent_to_init()
Removed. Instead the task being reparented to init is referred
directly to init's credentials.
NOTE! This results in the loss of some state: SELinux's osid no
longer records the sid of the thread that forked it.
(*) security_key_alloc(), ->key_alloc()
(*) security_key_permission(), ->key_permission()
Changed. These now take cred pointers rather than task pointers to
refer to the security context.
(4) sys_capset().
This has been simplified and uses less locking. The LSM functions it
calls have been merged.
(5) reparent_to_kthreadd().
This gives the current thread the same credentials as init by simply using
commit_thread() to point that way.
(6) __sigqueue_alloc() and switch_uid()
__sigqueue_alloc() can't stop the target task from changing its creds
beneath it, so this function gets a reference to the currently applicable
user_struct which it then passes into the sigqueue struct it returns if
successful.
switch_uid() is now called from commit_creds(), and possibly should be
folded into that. commit_creds() should take care of protecting
__sigqueue_alloc().
(7) [sg]et[ug]id() and co and [sg]et_current_groups.
The set functions now all use prepare_creds(), commit_creds() and
abort_creds() to build and check a new set of credentials before applying
it.
security_task_set[ug]id() is called inside the prepared section. This
guarantees that nothing else will affect the creds until we've finished.
The calling of set_dumpable() has been moved into commit_creds().
Much of the functionality of set_user() has been moved into
commit_creds().
The get functions all simply access the data directly.
(8) security_task_prctl() and cap_task_prctl().
security_task_prctl() has been modified to return -ENOSYS if it doesn't
want to handle a function, or otherwise return the return value directly
rather than through an argument.
Additionally, cap_task_prctl() now prepares a new set of credentials, even
if it doesn't end up using it.
(9) Keyrings.
A number of changes have been made to the keyrings code:
(a) switch_uid_keyring(), copy_keys(), exit_keys() and suid_keys() have
all been dropped and built in to the credentials functions directly.
They may want separating out again later.
(b) key_alloc() and search_process_keyrings() now take a cred pointer
rather than a task pointer to specify the security context.
(c) copy_creds() gives a new thread within the same thread group a new
thread keyring if its parent had one, otherwise it discards the thread
keyring.
(d) The authorisation key now points directly to the credentials to extend
the search into rather pointing to the task that carries them.
(e) Installing thread, process or session keyrings causes a new set of
credentials to be created, even though it's not strictly necessary for
process or session keyrings (they're shared).
(10) Usermode helper.
The usermode helper code now carries a cred struct pointer in its
subprocess_info struct instead of a new session keyring pointer. This set
of credentials is derived from init_cred and installed on the new process
after it has been cloned.
call_usermodehelper_setup() allocates the new credentials and
call_usermodehelper_freeinfo() discards them if they haven't been used. A
special cred function (prepare_usermodeinfo_creds()) is provided
specifically for call_usermodehelper_setup() to call.
call_usermodehelper_setkeys() adjusts the credentials to sport the
supplied keyring as the new session keyring.
(11) SELinux.
SELinux has a number of changes, in addition to those to support the LSM
interface changes mentioned above:
(a) selinux_setprocattr() no longer does its check for whether the
current ptracer can access processes with the new SID inside the lock
that covers getting the ptracer's SID. Whilst this lock ensures that
the check is done with the ptracer pinned, the result is only valid
until the lock is released, so there's no point doing it inside the
lock.
(12) is_single_threaded().
This function has been extracted from selinux_setprocattr() and put into
a file of its own in the lib/ directory as join_session_keyring() now
wants to use it too.
The code in SELinux just checked to see whether a task shared mm_structs
with other tasks (CLONE_VM), but that isn't good enough. We really want
to know if they're part of the same thread group (CLONE_THREAD).
(13) nfsd.
The NFS server daemon now has to use the COW credentials to set the
credentials it is going to use. It really needs to pass the credentials
down to the functions it calls, but it can't do that until other patches
in this series have been applied.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-14 02:39:23 +03:00
|
|
|
extern int install_thread_keyring_to_cred(struct cred *cred);
|
2019-05-22 16:06:51 +03:00
|
|
|
extern void key_fsuid_changed(struct cred *new_cred);
|
|
|
|
extern void key_fsgid_changed(struct cred *new_cred);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void key_init(void);
|
|
|
|
|
|
|
|
#else /* CONFIG_KEYS */
|
|
|
|
|
|
|
|
#define key_validate(k) 0
|
|
|
|
#define key_serial(k) 0
|
2005-06-24 09:00:51 +04:00
|
|
|
#define key_get(k) ({ NULL; })
|
2008-10-12 08:10:50 +04:00
|
|
|
#define key_revoke(k) do { } while(0)
|
2012-05-11 13:56:56 +04:00
|
|
|
#define key_invalidate(k) do { } while(0)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define key_put(k) do { } while(0)
|
2005-09-28 20:03:15 +04:00
|
|
|
#define key_ref_put(k) do { } while(0)
|
KEYS: Alter use of key instantiation link-to-keyring argument
Alter the use of the key instantiation and negation functions' link-to-keyring
arguments. Currently this specifies a keyring in the target process to link
the key into, creating the keyring if it doesn't exist. This, however, can be
a problem for copy-on-write credentials as it means that the instantiating
process can alter the credentials of the requesting process.
This patch alters the behaviour such that:
(1) If keyctl_instantiate_key() or keyctl_negate_key() are given a specific
keyring by ID (ringid >= 0), then that keyring will be used.
(2) If keyctl_instantiate_key() or keyctl_negate_key() are given one of the
special constants that refer to the requesting process's keyrings
(KEY_SPEC_*_KEYRING, all <= 0), then:
(a) If sys_request_key() was given a keyring to use (destringid) then the
key will be attached to that keyring.
(b) If sys_request_key() was given a NULL keyring, then the key being
instantiated will be attached to the default keyring as set by
keyctl_set_reqkey_keyring().
(3) No extra link will be made.
Decision point (1) follows current behaviour, and allows those instantiators
who've searched for a specifically named keyring in the requestor's keyring so
as to partition the keys by type to still have their named keyrings.
Decision point (2) allows the requestor to make sure that the key or keys that
get produced by request_key() go where they want, whilst allowing the
instantiator to request that the key is retained. This is mainly useful for
situations where the instantiator makes a secondary request, the key for which
should be retained by the initial requestor:
+-----------+ +--------------+ +--------------+
| | | | | |
| Requestor |------->| Instantiator |------->| Instantiator |
| | | | | |
+-----------+ +--------------+ +--------------+
request_key() request_key()
This might be useful, for example, in Kerberos, where the requestor requests a
ticket, and then the ticket instantiator requests the TGT, which someone else
then has to go and fetch. The TGT, however, should be retained in the
keyrings of the requestor, not the first instantiator. To make this explict
an extra special keyring constant is also added.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>
2008-11-14 02:39:14 +03:00
|
|
|
#define make_key_ref(k, p) NULL
|
|
|
|
#define key_ref_to_ptr(k) NULL
|
2005-09-28 20:03:15 +04:00
|
|
|
#define is_key_possessed(k) 0
|
2019-05-22 16:06:51 +03:00
|
|
|
#define key_fsuid_changed(c) do { } while(0)
|
|
|
|
#define key_fsgid_changed(c) do { } while(0)
|
2005-04-17 02:20:36 +04:00
|
|
|
#define key_init() do { } while(0)
|
|
|
|
|
|
|
|
#endif /* CONFIG_KEYS */
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* _LINUX_KEY_H */
|