Re: [PATCH 4/4] forget_original_parent: cleanup ptrace pathes

From: Oleg Nesterov
Date: Tue Feb 10 2009 - 18:43:00 EST


On 02/10, Roland McGrath wrote:
>
> > How about below? Modulo comments and some other cleanups. For example,
> > I think it is better to move the changing of ->real_parent into
> > reparent_thread().
>
> The exact split between reparent_thread and forget_original_parent (and
> their names) never made much sense to me.
>
> If ptrace_exit does its own lock/unlock, then it could move much earlier.
> I'd be inclined to do it right before exit_signals().

Yes. But since I am paranoid, can we move the callsite later? I mean,
I'd prefer to make a separate (trivial) patch which moves it.

> But it should at
> least short-circuit and not lock for list_empty(->ptraced), so we're not
> adding a whole lock_irq/unlock_irq to the common case of no ptrace use.

Agreed, and probably forget_original_parent() can check empty(->children)
too.

> > xxx = &p->real_parent->children;
> > if (reparent_thread(father, p))
> > xxx = &child_dead;
> > list_move_tail(&p->sibling, xxx);;
>
> I'd thought of this before. But I didn't mention it because I was afraid
> to wonder what might care about the use of ->sibling. It really looks like
> nothing does.

Yes, nobody should at least. Nobody can find this task on its own list.

> This is clearly the clean and nice way to go if there is no
> problem with it.

OK, will try to send the patches soon.

> This change and moving ptrace_exit around should probably be separate patches.

Yes, yes, sure.


If you don't mind, I'd prefer to make these changes on top of [PATCH 3/4],
reparent_thread-fix-a-zombie-leak-if-sbin-init-ignores-sigchld.patch
(and this one should be dropped).

Because that patch fixes the bug and changes the behaviour, while the
discussed changes are cleanups.

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/