[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20060809143816.GA142@oleg>
Date: Wed, 9 Aug 2006 18:38:16 +0400
From: Oleg Nesterov <oleg@...sign.ru>
To: Andrew Morton <akpm@...l.org>, Kirill Korotaev <dev@...ru>
Cc: Dave Hansen <haveblue@...ibm.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sys_getppid oopses on debug kernel (v2)
Andrew Morton wrote:
>
> Although I'm not sure it's needed for this problem. A getppid() which does
>
> asmlinkage long sys_getppid(void)
> {
> int pid;
>
> read_lock(&tasklist_lock);
> pid = current->group_leader->real_parent->tgid;
> read_unlock(&tasklist_lock);
>
> return pid;
> }
>
> seems like a fine implementation to me ;)
Why do we need to use ->group_leader? All threads should have the same
->real_parent.
Why do we need tasklist_lock? I think rcu_read_lock() is enough.
In other words, do you see any problems with this code
smlinkage long sys_getppid(void)
{
int pid;
rcu_read_lock();
pid = rcu_dereference(current->real_parent)->tgid;
rcu_read_unlock();
return pid;
}
? Yes, we may read a stale value for ->real_parent, but the memory
can't be freed while we are under rcu_read_lock(). And in this case
the returned value is ok because the task could be reparented just
after return anyway.
Oleg.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists