SELinux: allow preemption between transition permission checks
In security_get_user_sids, move the transition permission checks outside of the section holding the policy rdlock, and use the AVC to perform the checks, calling cond_resched after each one. These changes should allow preemption between the individual checks and enable caching of the results. It may however increase the overall time spent in the function in some cases, particularly in the cache miss case. The long term fix will be to take much of this logic to userspace by exporting additional state via selinuxfs, and ultimately deprecating and eliminating this interface from the kernel. Tested-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
committed by
James Morris
parent
9dc9978084
commit
2c3c05dbcb
@@ -1592,9 +1592,10 @@ static int selinux_vm_enough_memory(long pages)
|
||||
rc = secondary_ops->capable(current, CAP_SYS_ADMIN);
|
||||
if (rc == 0)
|
||||
rc = avc_has_perm_noaudit(tsec->sid, tsec->sid,
|
||||
SECCLASS_CAPABILITY,
|
||||
CAP_TO_MASK(CAP_SYS_ADMIN),
|
||||
NULL);
|
||||
SECCLASS_CAPABILITY,
|
||||
CAP_TO_MASK(CAP_SYS_ADMIN),
|
||||
0,
|
||||
NULL);
|
||||
|
||||
if (rc == 0)
|
||||
cap_sys_admin = 1;
|
||||
@@ -4626,7 +4627,7 @@ static int selinux_setprocattr(struct task_struct *p,
|
||||
if (p->ptrace & PT_PTRACED) {
|
||||
error = avc_has_perm_noaudit(tsec->ptrace_sid, sid,
|
||||
SECCLASS_PROCESS,
|
||||
PROCESS__PTRACE, &avd);
|
||||
PROCESS__PTRACE, 0, &avd);
|
||||
if (!error)
|
||||
tsec->sid = sid;
|
||||
task_unlock(p);
|
||||
|
||||
Reference in New Issue
Block a user