Commit cad4ea54 authored by Eric W. Biederman's avatar Eric W. Biederman

rlimit: Properly call security_task_setrlimit

Modify do_prlimit to call security_task_setrlimit passing the task
whose rlimit we are changing not the tsk->group_leader.

In general this should not matter as the lsms implementing
security_task_setrlimit apparmor and selinux both examine the
task->cred to see what should be allowed on the destination task.

That task->cred is shared between tasks created with CLONE_THREAD
unless thread keyrings are in play, in which case both apparmor and
selinux create duplicate security contexts.

So the only time when it will matter which thread is passed to
security_task_setrlimit is if one of the threads of a process performs
an operation that changes only it's credentials.  At which point if a
thread has done that we don't want to hide that information from the
lsms.

So fix the call of security_task_setrlimit.  With the removal
of tsk->group_leader this makes the code slightly faster,
more comprehensible and maintainable.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent d27158c0
...@@ -1396,8 +1396,7 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource, ...@@ -1396,8 +1396,7 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
!capable(CAP_SYS_RESOURCE)) !capable(CAP_SYS_RESOURCE))
retval = -EPERM; retval = -EPERM;
if (!retval) if (!retval)
retval = security_task_setrlimit(tsk->group_leader, retval = security_task_setrlimit(tsk, resource, new_rlim);
resource, new_rlim);
if (resource == RLIMIT_CPU && new_rlim->rlim_cur == 0) { if (resource == RLIMIT_CPU && new_rlim->rlim_cur == 0) {
/* /*
* The caller is asking for an immediate RLIMIT_CPU * The caller is asking for an immediate RLIMIT_CPU
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment