Re: [PATCH v3 06/11] rlimits: do security check under task_lock

From: Oleg Nesterov
Date: Wed Jun 23 2010 - 13:58:06 EST


On 06/23, Jiri Slaby wrote:
>
> On 06/23/2010 06:12 PM, Oleg Nesterov wrote:
> > On 06/23, Jiri Slaby wrote:
> >>
> >> BTW this capable() has the exactly same problem with being called with
> >> task_lock held. Is it OK to move it completely out of critical section?
> >> I'm asking because it sets a current->flags SU bit used for accounting.
> >> If I move it out of the section, it will set the bit always.
> >
> > Well, with all these delays I do not know what "exactly same problem"
> > means ;) Please explain?
>
> As I wrote: that the capable() is called with task_lock held.

Ah, got it, yes.

> > selinux_task_setrlimit()->current_has_perm()->current_sid()->current_cred()

I meant
selinux_task_setrlimit(p)->current_has_perm(p)->task_sid(p)->__task_cred(p)

> I still see no way how this is wrong. We want to check whether current
> thread has capabilities to change (someone else's) rlimits.

Yes. but what is "someone else" ?

IIRC, one of your patches (correctly) changes security_task_setrlimit()
to have the new argument, p == "someone else", correct?

Now, the result of security check depends on __task_cred(p) above, and
thus depends on which thread we choose to change rlimits.

I think it makes more sense to always pass ->group_leader as an argument
to security_task_setrlimit(p). But probably I missed something, I do not
remember what exactly other patches do.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/