Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris: "Highlights: IMA: - provide ">" and "<" operators for fowner/uid/euid rules KEYS: - add a system blacklist keyring - add KEYCTL_RESTRICT_KEYRING, exposes keyring link restriction functionality to userland via keyctl() LSM: - harden LSM API with __ro_after_init - add prlmit security hook, implement for SELinux - revive security_task_alloc hook TPM: - implement contextual TPM command 'spaces'" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (98 commits) tpm: Fix reference count to main device tpm_tis: convert to using locality callbacks tpm: fix handling of the TPM 2.0 event logs tpm_crb: remove a cruft constant keys: select CONFIG_CRYPTO when selecting DH / KDF apparmor: Make path_max parameter readonly apparmor: fix parameters so that the permission test is bypassed at boot apparmor: fix invalid reference to index variable of iterator line 836 apparmor: use SHASH_DESC_ON_STACK security/apparmor/lsm.c: set debug messages apparmor: fix boolreturn.cocci warnings Smack: Use GFP_KERNEL for smk_netlbl_mls(). smack: fix double free in smack_parse_opts_str() KEYS: add SP800-56A KDF support for DH KEYS: Keyring asymmetric key restrict method with chaining KEYS: Restrict asymmetric key linkage using a specific keychain KEYS: Add a lookup_restriction function for the asymmetric key type KEYS: Add KEYCTL_RESTRICT_KEYRING KEYS: Consistent ordering for __key_link_begin and restrict check KEYS: Add an optional lookup_restriction hook to key_type ...
This commit is contained in:
@@ -295,6 +295,13 @@ struct compat_old_sigaction {
|
||||
};
|
||||
#endif
|
||||
|
||||
struct compat_keyctl_kdf_params {
|
||||
compat_uptr_t hashname;
|
||||
compat_uptr_t otherinfo;
|
||||
__u32 otherinfolen;
|
||||
__u32 __spare[8];
|
||||
};
|
||||
|
||||
struct compat_statfs;
|
||||
struct compat_statfs64;
|
||||
struct compat_old_linux_dirent;
|
||||
|
@@ -219,6 +219,12 @@ extern struct cred init_cred;
|
||||
# define INIT_TASK_TI(tsk)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURITY
|
||||
#define INIT_TASK_SECURITY .security = NULL,
|
||||
#else
|
||||
#define INIT_TASK_SECURITY
|
||||
#endif
|
||||
|
||||
/*
|
||||
* INIT_TASK is used to set up the first task table, touch at
|
||||
* your own risk!. Base=0, limit=0x1fffff (=2MB)
|
||||
@@ -298,6 +304,7 @@ extern struct cred init_cred;
|
||||
INIT_NUMA_BALANCING(tsk) \
|
||||
INIT_KASAN(tsk) \
|
||||
INIT_LIVEPATCH(tsk) \
|
||||
INIT_TASK_SECURITY \
|
||||
}
|
||||
|
||||
|
||||
|
@@ -147,6 +147,14 @@ struct key_type {
|
||||
*/
|
||||
request_key_actor_t request_key;
|
||||
|
||||
/* Look up a keyring access restriction (optional)
|
||||
*
|
||||
* - NULL is a valid return value (meaning the requested restriction
|
||||
* is known but will never block addition of a key)
|
||||
* - should return -EINVAL if the restriction is unknown
|
||||
*/
|
||||
struct key_restriction *(*lookup_restriction)(const char *params);
|
||||
|
||||
/* internal fields */
|
||||
struct list_head link; /* link in types list */
|
||||
struct lock_class_key lock_class; /* key->sem lock class */
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/assoc_array.h>
|
||||
#include <linux/refcount.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/uidgid.h>
|
||||
@@ -126,6 +127,17 @@ static inline bool is_key_possessed(const key_ref_t key_ref)
|
||||
return (unsigned long) key_ref & 1UL;
|
||||
}
|
||||
|
||||
typedef int (*key_restrict_link_func_t)(struct key *dest_keyring,
|
||||
const struct key_type *type,
|
||||
const union key_payload *payload,
|
||||
struct key *restriction_key);
|
||||
|
||||
struct key_restriction {
|
||||
key_restrict_link_func_t check;
|
||||
struct key *key;
|
||||
struct key_type *keytype;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* authentication token / access credential / keyring
|
||||
@@ -135,7 +147,7 @@ static inline bool is_key_possessed(const key_ref_t key_ref)
|
||||
* - Kerberos TGTs and tickets
|
||||
*/
|
||||
struct key {
|
||||
atomic_t usage; /* number of references */
|
||||
refcount_t usage; /* number of references */
|
||||
key_serial_t serial; /* key serial number */
|
||||
union {
|
||||
struct list_head graveyard_link;
|
||||
@@ -205,18 +217,17 @@ struct key {
|
||||
};
|
||||
|
||||
/* This is set on a keyring to restrict the addition of a link to a key
|
||||
* to it. If this method isn't provided then it is assumed that the
|
||||
* to it. If this structure isn't provided then it is assumed that the
|
||||
* keyring is open to any addition. It is ignored for non-keyring
|
||||
* keys.
|
||||
* keys. Only set this value using keyring_restrict(), keyring_alloc(),
|
||||
* or key_alloc().
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
int (*restrict_link)(struct key *keyring,
|
||||
const struct key_type *type,
|
||||
const union key_payload *payload);
|
||||
struct key_restriction *restrict_link;
|
||||
};
|
||||
|
||||
extern struct key *key_alloc(struct key_type *type,
|
||||
@@ -225,9 +236,7 @@ extern struct key *key_alloc(struct key_type *type,
|
||||
const struct cred *cred,
|
||||
key_perm_t perm,
|
||||
unsigned long flags,
|
||||
int (*restrict_link)(struct key *,
|
||||
const struct key_type *,
|
||||
const union key_payload *));
|
||||
struct key_restriction *restrict_link);
|
||||
|
||||
|
||||
#define KEY_ALLOC_IN_QUOTA 0x0000 /* add to quota, reject if would overrun */
|
||||
@@ -242,7 +251,7 @@ extern void key_put(struct key *key);
|
||||
|
||||
static inline struct key *__key_get(struct key *key)
|
||||
{
|
||||
atomic_inc(&key->usage);
|
||||
refcount_inc(&key->usage);
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -303,14 +312,13 @@ extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid
|
||||
const struct cred *cred,
|
||||
key_perm_t perm,
|
||||
unsigned long flags,
|
||||
int (*restrict_link)(struct key *,
|
||||
const struct key_type *,
|
||||
const union key_payload *),
|
||||
struct key_restriction *restrict_link,
|
||||
struct key *dest);
|
||||
|
||||
extern int restrict_link_reject(struct key *keyring,
|
||||
const struct key_type *type,
|
||||
const union key_payload *payload);
|
||||
const union key_payload *payload,
|
||||
struct key *restriction_key);
|
||||
|
||||
extern int keyring_clear(struct key *keyring);
|
||||
|
||||
@@ -321,6 +329,9 @@ extern key_ref_t keyring_search(key_ref_t keyring,
|
||||
extern int keyring_add_key(struct key *keyring,
|
||||
struct key *key);
|
||||
|
||||
extern int keyring_restrict(key_ref_t keyring, const char *type,
|
||||
const char *restriction);
|
||||
|
||||
extern struct key *key_lookup(key_serial_t id);
|
||||
|
||||
static inline key_serial_t key_serial(const struct key *key)
|
||||
|
@@ -533,8 +533,13 @@
|
||||
* manual page for definitions of the @clone_flags.
|
||||
* @clone_flags contains the flags indicating what should be shared.
|
||||
* Return 0 if permission is granted.
|
||||
* @task_alloc:
|
||||
* @task task being allocated.
|
||||
* @clone_flags contains the flags indicating what should be shared.
|
||||
* Handle allocation of task-related resources.
|
||||
* Returns a zero on success, negative values on failure.
|
||||
* @task_free:
|
||||
* @task task being freed
|
||||
* @task task about to be freed.
|
||||
* Handle release of task-related resources. (Note that this can be called
|
||||
* from interrupt context.)
|
||||
* @cred_alloc_blank:
|
||||
@@ -630,10 +635,19 @@
|
||||
* Check permission before getting the ioprio value of @p.
|
||||
* @p contains the task_struct of process.
|
||||
* Return 0 if permission is granted.
|
||||
* @task_prlimit:
|
||||
* Check permission before getting and/or setting the resource limits of
|
||||
* another task.
|
||||
* @cred points to the cred structure for the current task.
|
||||
* @tcred points to the cred structure for the target task.
|
||||
* @flags contains the LSM_PRLIMIT_* flag bits indicating whether the
|
||||
* resource limits are being read, modified, or both.
|
||||
* Return 0 if permission is granted.
|
||||
* @task_setrlimit:
|
||||
* Check permission before setting the resource limits of the current
|
||||
* process for @resource to @new_rlim. The old resource limit values can
|
||||
* be examined by dereferencing (current->signal->rlim + resource).
|
||||
* Check permission before setting the resource limits of process @p
|
||||
* for @resource to @new_rlim. The old resource limit values can
|
||||
* be examined by dereferencing (p->signal->rlim + resource).
|
||||
* @p points to the task_struct for the target task's group leader.
|
||||
* @resource contains the resource whose limit is being set.
|
||||
* @new_rlim contains the new limits for @resource.
|
||||
* Return 0 if permission is granted.
|
||||
@@ -1473,6 +1487,7 @@ union security_list_options {
|
||||
int (*file_open)(struct file *file, const struct cred *cred);
|
||||
|
||||
int (*task_create)(unsigned long clone_flags);
|
||||
int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
|
||||
void (*task_free)(struct task_struct *task);
|
||||
int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
|
||||
void (*cred_free)(struct cred *cred);
|
||||
@@ -1494,6 +1509,8 @@ union security_list_options {
|
||||
int (*task_setnice)(struct task_struct *p, int nice);
|
||||
int (*task_setioprio)(struct task_struct *p, int ioprio);
|
||||
int (*task_getioprio)(struct task_struct *p);
|
||||
int (*task_prlimit)(const struct cred *cred, const struct cred *tcred,
|
||||
unsigned int flags);
|
||||
int (*task_setrlimit)(struct task_struct *p, unsigned int resource,
|
||||
struct rlimit *new_rlim);
|
||||
int (*task_setscheduler)(struct task_struct *p);
|
||||
@@ -1737,6 +1754,7 @@ struct security_hook_heads {
|
||||
struct list_head file_receive;
|
||||
struct list_head file_open;
|
||||
struct list_head task_create;
|
||||
struct list_head task_alloc;
|
||||
struct list_head task_free;
|
||||
struct list_head cred_alloc_blank;
|
||||
struct list_head cred_free;
|
||||
@@ -1755,6 +1773,7 @@ struct security_hook_heads {
|
||||
struct list_head task_setnice;
|
||||
struct list_head task_setioprio;
|
||||
struct list_head task_getioprio;
|
||||
struct list_head task_prlimit;
|
||||
struct list_head task_setrlimit;
|
||||
struct list_head task_setscheduler;
|
||||
struct list_head task_getscheduler;
|
||||
@@ -1908,6 +1927,13 @@ static inline void security_delete_hooks(struct security_hook_list *hooks,
|
||||
}
|
||||
#endif /* CONFIG_SECURITY_SELINUX_DISABLE */
|
||||
|
||||
/* Currently required to handle SELinux runtime hook disable. */
|
||||
#ifdef CONFIG_SECURITY_WRITABLE_HOOKS
|
||||
#define __lsm_ro_after_init
|
||||
#else
|
||||
#define __lsm_ro_after_init __ro_after_init
|
||||
#endif /* CONFIG_SECURITY_WRITABLE_HOOKS */
|
||||
|
||||
extern int __init security_module_enable(const char *module);
|
||||
extern void __init capability_add_hooks(void);
|
||||
#ifdef CONFIG_SECURITY_YAMA
|
||||
|
@@ -1046,6 +1046,10 @@ struct task_struct {
|
||||
#endif
|
||||
#ifdef CONFIG_LIVEPATCH
|
||||
int patch_state;
|
||||
#endif
|
||||
#ifdef CONFIG_SECURITY
|
||||
/* Used by LSM modules for access restriction: */
|
||||
void *security;
|
||||
#endif
|
||||
/* CPU-specific state of this task: */
|
||||
struct thread_struct thread;
|
||||
|
@@ -133,6 +133,10 @@ extern unsigned long dac_mmap_min_addr;
|
||||
/* setfsuid or setfsgid, id0 == fsuid or fsgid */
|
||||
#define LSM_SETID_FS 8
|
||||
|
||||
/* Flags for security_task_prlimit(). */
|
||||
#define LSM_PRLIMIT_READ 1
|
||||
#define LSM_PRLIMIT_WRITE 2
|
||||
|
||||
/* forward declares to avoid warnings */
|
||||
struct sched_param;
|
||||
struct request_sock;
|
||||
@@ -304,6 +308,7 @@ int security_file_send_sigiotask(struct task_struct *tsk,
|
||||
int security_file_receive(struct file *file);
|
||||
int security_file_open(struct file *file, const struct cred *cred);
|
||||
int security_task_create(unsigned long clone_flags);
|
||||
int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
|
||||
void security_task_free(struct task_struct *task);
|
||||
int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
|
||||
void security_cred_free(struct cred *cred);
|
||||
@@ -324,6 +329,8 @@ void security_task_getsecid(struct task_struct *p, u32 *secid);
|
||||
int security_task_setnice(struct task_struct *p, int nice);
|
||||
int security_task_setioprio(struct task_struct *p, int ioprio);
|
||||
int security_task_getioprio(struct task_struct *p);
|
||||
int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
|
||||
unsigned int flags);
|
||||
int security_task_setrlimit(struct task_struct *p, unsigned int resource,
|
||||
struct rlimit *new_rlim);
|
||||
int security_task_setscheduler(struct task_struct *p);
|
||||
@@ -855,6 +862,12 @@ static inline int security_task_create(unsigned long clone_flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int security_task_alloc(struct task_struct *task,
|
||||
unsigned long clone_flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void security_task_free(struct task_struct *task)
|
||||
{ }
|
||||
|
||||
@@ -949,6 +962,13 @@ static inline int security_task_getioprio(struct task_struct *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int security_task_prlimit(const struct cred *cred,
|
||||
const struct cred *tcred,
|
||||
unsigned int flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int security_task_setrlimit(struct task_struct *p,
|
||||
unsigned int resource,
|
||||
struct rlimit *new_rlim)
|
||||
|
@@ -48,7 +48,8 @@ struct tpm_class_ops {
|
||||
u8 (*status) (struct tpm_chip *chip);
|
||||
bool (*update_timeouts)(struct tpm_chip *chip,
|
||||
unsigned long *timeout_cap);
|
||||
|
||||
int (*request_locality)(struct tpm_chip *chip, int loc);
|
||||
void (*relinquish_locality)(struct tpm_chip *chip, int loc);
|
||||
};
|
||||
|
||||
#if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
|
||||
|
Reference in New Issue
Block a user