Re: [PATCH] apparmor: remove the "task" arg frommay_change_ptraced_domain()

From: Richard Guy Briggs
Date: Thu Sep 26 2013 - 09:25:28 EST


On Tue, Sep 24, 2013 at 06:44:42PM +0200, Oleg Nesterov wrote:
> On 09/23, Richard Guy Briggs wrote:
> >
> > On Mon, Sep 16, 2013 at 04:20:35PM +0200, Oleg Nesterov wrote:
> > > Unless task == current ptrace_parent(task) is not safe even under
> > > rcu_read_lock() and most of the current users are not right.
> >
> > Could you point to an explanation of this?
>
> If this task exits before rcu_read_lock() ->parent can point to the
> already freed/reused memory.

Ok, understood. So even though the task may have exited, the task
struct pointer is still valid, but not the contents of the task struct
to which it points.

> (in the long term we should probably clear
> ->parent/real_parent/group_leader/more in __unhash_process(), but
> lets not discuss this right now ;)

...so that the contents are valid in a task struct of a task that has
exited.

Thanks for the (more obvious to me now) explanation.

> Oleg.

- RGB

--
Richard Guy Briggs <rbriggs@xxxxxxxxxx>
Senior Software Engineer
Kernel Security
AMER ENG Base Operating Systems
Remote, Ottawa, Canada
Voice: +1.647.777.2635
Internal: (81) 32635
Alt: +1.613.693.0684x3545
--
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/