Re: [PATCH] secure unlock_task_sighand() call

From: Oleg Nesterov
Date: Sat Dec 21 2013 - 13:26:41 EST


On 12/21, Linus Torvalds wrote:
>
> We have coredump serialization in exit_mm() that I think *should* make
> this all ok - if we still see p->mm matching our mm,

Yes. And the comment says:

lock_task_sighand(p)
must be used. Since p->mm != NULL and we hold ->mmap_sem
it can't fail.

IOW, this task can't pass exit_mm() and thus lock_task_sighand() can't
fail.

> > do {
> > if (p->mm) {
> > if (unlikely(p->mm == mm)) {
> > - lock_task_sighand(p, &flags);
> > - nr += zap_process(p, exit_code);
> > - unlock_task_sighand(p, &flags);
> > + if (lock_task_sighand(p, &flags) {
> > + nr += zap_process(p, exit_code);
> > + unlock_task_sighand(p, &flags);
> > + }

I too do not think this is needed. But perhaps BUG_ON() make sense.

Note: just in case, this has another problem: while_each_thread() is racy.
We already have the initial fixes in -mm, this code (as other users)
should be converted to use for_each_thread(), I'll send the patch(es).

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/