mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
LSM: generalize flag passing to security_capable
This patch provides a general mechanism for passing flags to the security_capable LSM hook. It replaces the specific 'audit' flag that is used to tell security_capable whether it should log an audit message for the given capability check. The reason for generalizing this flag passing is so we can add an additional flag that signifies whether security_capable is being called by a setid syscall (which is needed by the proposed SafeSetID LSM). Signed-off-by: Micah Morton <mortonm@chromium.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: James Morris <james.morris@microsoft.com>
This commit is contained in:
parent
2233975cd7
commit
c1a85a00ea
13 changed files with 71 additions and 67 deletions
|
@ -68,7 +68,7 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
|
|||
* kernel's capable() and has_capability() returns 1 for this case.
|
||||
*/
|
||||
int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
|
||||
int cap, int audit)
|
||||
int cap, unsigned int opts)
|
||||
{
|
||||
struct user_namespace *ns = targ_ns;
|
||||
|
||||
|
@ -222,12 +222,11 @@ int cap_capget(struct task_struct *target, kernel_cap_t *effective,
|
|||
*/
|
||||
static inline int cap_inh_is_capped(void)
|
||||
{
|
||||
|
||||
/* they are so limited unless the current task has the CAP_SETPCAP
|
||||
* capability
|
||||
*/
|
||||
if (cap_capable(current_cred(), current_cred()->user_ns,
|
||||
CAP_SETPCAP, SECURITY_CAP_AUDIT) == 0)
|
||||
CAP_SETPCAP, CAP_OPT_NONE) == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1208,8 +1207,9 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
|
|||
|| ((old->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/
|
||||
|| (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/
|
||||
|| (cap_capable(current_cred(),
|
||||
current_cred()->user_ns, CAP_SETPCAP,
|
||||
SECURITY_CAP_AUDIT) != 0) /*[4]*/
|
||||
current_cred()->user_ns,
|
||||
CAP_SETPCAP,
|
||||
CAP_OPT_NONE) != 0) /*[4]*/
|
||||
/*
|
||||
* [1] no changing of bits that are locked
|
||||
* [2] no unlocking of locks
|
||||
|
@ -1304,9 +1304,10 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages)
|
|||
{
|
||||
int cap_sys_admin = 0;
|
||||
|
||||
if (cap_capable(current_cred(), &init_user_ns, CAP_SYS_ADMIN,
|
||||
SECURITY_CAP_NOAUDIT) == 0)
|
||||
if (cap_capable(current_cred(), &init_user_ns,
|
||||
CAP_SYS_ADMIN, CAP_OPT_NOAUDIT) == 0)
|
||||
cap_sys_admin = 1;
|
||||
|
||||
return cap_sys_admin;
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1326,7 @@ int cap_mmap_addr(unsigned long addr)
|
|||
|
||||
if (addr < dac_mmap_min_addr) {
|
||||
ret = cap_capable(current_cred(), &init_user_ns, CAP_SYS_RAWIO,
|
||||
SECURITY_CAP_AUDIT);
|
||||
CAP_OPT_NONE);
|
||||
/* set PF_SUPERPRIV if it turns out we allow the low mmap */
|
||||
if (ret == 0)
|
||||
current->flags |= PF_SUPERPRIV;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue