mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
[PATCH] SELinux: extend task_kill hook to handle signals sent by AIO completion
This patch extends the security_task_kill hook to handle signals sent by AIO completion. In this case, the secid of the task responsible for the signal needs to be obtained and saved earlier, so a security_task_getsecid() hook is added, and then this saved value is passed subsequently to the extended task_kill hook for use in checking. Signed-off-by: David Quigley <[email protected]> Signed-off-by: James Morris <[email protected]> Cc: Stephen Smalley <[email protected]> Cc: Chris Wright <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
ed11d9eb22
commit
f9008e4c5c
3 changed files with 40 additions and 9 deletions
|
|
@ -506,6 +506,9 @@ static int dummy_task_getsid (struct task_struct *p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void dummy_task_getsecid (struct task_struct *p, u32 *secid)
|
||||
{ }
|
||||
|
||||
static int dummy_task_setgroups (struct group_info *group_info)
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -548,7 +551,7 @@ static int dummy_task_wait (struct task_struct *p)
|
|||
}
|
||||
|
||||
static int dummy_task_kill (struct task_struct *p, struct siginfo *info,
|
||||
int sig)
|
||||
int sig, u32 secid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -981,6 +984,7 @@ void security_fixup_ops (struct security_operations *ops)
|
|||
set_to_dummy_if_null(ops, task_setpgid);
|
||||
set_to_dummy_if_null(ops, task_getpgid);
|
||||
set_to_dummy_if_null(ops, task_getsid);
|
||||
set_to_dummy_if_null(ops, task_getsecid);
|
||||
set_to_dummy_if_null(ops, task_setgroups);
|
||||
set_to_dummy_if_null(ops, task_setnice);
|
||||
set_to_dummy_if_null(ops, task_setioprio);
|
||||
|
|
|
|||
|
|
@ -2644,6 +2644,11 @@ static int selinux_task_getsid(struct task_struct *p)
|
|||
return task_has_perm(current, p, PROCESS__GETSESSION);
|
||||
}
|
||||
|
||||
static void selinux_task_getsecid(struct task_struct *p, u32 *secid)
|
||||
{
|
||||
selinux_get_task_sid(p, secid);
|
||||
}
|
||||
|
||||
static int selinux_task_setgroups(struct group_info *group_info)
|
||||
{
|
||||
/* See the comment for setuid above. */
|
||||
|
|
@ -2700,12 +2705,14 @@ static int selinux_task_movememory(struct task_struct *p)
|
|||
return task_has_perm(current, p, PROCESS__SETSCHED);
|
||||
}
|
||||
|
||||
static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int sig)
|
||||
static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
|
||||
int sig, u32 secid)
|
||||
{
|
||||
u32 perm;
|
||||
int rc;
|
||||
struct task_security_struct *tsec;
|
||||
|
||||
rc = secondary_ops->task_kill(p, info, sig);
|
||||
rc = secondary_ops->task_kill(p, info, sig, secid);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
|
|
@ -2716,8 +2723,12 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int si
|
|||
perm = PROCESS__SIGNULL; /* null signal; existence test */
|
||||
else
|
||||
perm = signal_to_av(sig);
|
||||
|
||||
return task_has_perm(current, p, perm);
|
||||
tsec = p->security;
|
||||
if (secid)
|
||||
rc = avc_has_perm(secid, tsec->sid, SECCLASS_PROCESS, perm, NULL);
|
||||
else
|
||||
rc = task_has_perm(current, p, perm);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int selinux_task_prctl(int option,
|
||||
|
|
@ -4434,6 +4445,7 @@ static struct security_operations selinux_ops = {
|
|||
.task_setpgid = selinux_task_setpgid,
|
||||
.task_getpgid = selinux_task_getpgid,
|
||||
.task_getsid = selinux_task_getsid,
|
||||
.task_getsecid = selinux_task_getsecid,
|
||||
.task_setgroups = selinux_task_setgroups,
|
||||
.task_setnice = selinux_task_setnice,
|
||||
.task_setioprio = selinux_task_setioprio,
|
||||
|
|
|
|||
Loading…
Reference in a new issue