public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@osdl.org>, Kirill Korotaev <dev@sw.ru>
Cc: Dave Hansen <haveblue@us.ibm.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sys_getppid oopses on debug kernel (v2)
Date: Wed, 9 Aug 2006 18:38:16 +0400	[thread overview]
Message-ID: <20060809143816.GA142@oleg> (raw)

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.


             reply	other threads:[~2006-08-09 10:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09 14:38 Oleg Nesterov [this message]
2006-08-09 12:08 ` [PATCH] sys_getppid oopses on debug kernel (v2) Kirill Korotaev
2006-08-09 16:54   ` Oleg Nesterov
2006-08-09 13:02     ` Kirill Korotaev
2006-08-09 18:24       ` [PATCH] sys_getppid-oopses-on-debug-kernel-v2-simplify Oleg Nesterov
  -- strict thread matches above, loose matches on Subject: below --
2006-08-08 15:50 [PATCH] sys_getppid oopses on debug kernel (v2) Kirill Korotaev
2006-08-08 16:09 ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060809143816.GA142@oleg \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=dev@sw.ru \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox