public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: "Eric W. Biederman" <ebiederm@xmission.com>,
	Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Pavel Emelyanov <xemul@openvz.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] do_task_stat: don't use task_pid_nr_ns() lockless
Date: Mon, 19 Nov 2007 12:30:15 +0300	[thread overview]
Message-ID: <474157A7.1060504@openvz.org> (raw)
In-Reply-To: <m1fxz4ws2z.fsf@ebiederm.dsl.xmission.com>

Eric W. Biederman wrote:
> Oleg Nesterov <oleg@tv-sign.ru> writes:
> 
>> Without rcu/tasklist/siglock lock task_pid_nr_ns() may read the freed memory,
>> move the callsite under ->siglock.
>>
>> Sadly, we can report pid == 0 if the task was detached.
> 
> We only get detached in release_task so it is a pretty small window
> where we can return pid == 0.  Usually get_task_pid will fail first
> and we will return -ESRCH.  Still the distance from open to 
> 
> There is another bug in here as well.  current->nsproxy->pid_ns is wrong.
> What we want is: ns = dentry->d_sb->s_fs_info;

Actually I thought about this recently - if we produce the list
of tasks based on the sb's namespace, then we should fill the
tasks' files according to the sb's namespace as well, not according
to the current namespace.

> Otherwise we will have file descriptor passing races and the like.

Can you elaborate?

> We could also do: proc_pid(inode) to get the pid, which is a little
> more race free, and will prevent us from returning pid == 0.
> 
> In either event it looks like we need to implement some proper
> file operations for these proc files, maybe even going to seq file
> status.
> 
> Eric
> 


  reply	other threads:[~2007-11-19  9:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-17 18:31 [PATCH] do_task_stat: don't use task_pid_nr_ns() lockless Oleg Nesterov
2007-11-17 20:11 ` Eric W. Biederman
2007-11-19  9:30   ` Pavel Emelyanov [this message]
2007-11-19 18:04     ` Eric W. Biederman
2007-11-19  9:31 ` Pavel Emelyanov
2007-11-19 21:59 ` [PATCH 0/4] proc: Cleanup status files Eric W. Biederman
2007-11-19 22:04   ` [PATCH 1/4] proc: Implement proc_single_file_operations Eric W. Biederman
2007-11-19 22:06     ` [PATCH 2/4] proc: Rewrite do_task_stat to correctly handle pid namespaces Eric W. Biederman
2007-11-19 22:10       ` [PATCH 3/4] proc: seqfile convert proc_pid_status to properly " Eric W. Biederman
2007-11-19 22:13         ` [PATCH] proc: seqfile convert proc_pid_statm Eric W. Biederman
2007-11-20 10:34   ` [PATCH 0/4] proc: Cleanup status files Pavel Emelyanov
2007-11-19 22:30 ` [PATCH] proc: Proper pidns handling for /proc/self Eric W. Biederman

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=474157A7.1060504@openvz.org \
    --to=xemul@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    /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