From: "Serge E. Hallyn" <serue@us.ibm.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Vitaliy Gusev <vgusev@openvz.org>, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC][PATCH] Pid namespaces vs locks interaction
Date: Fri, 7 Dec 2007 08:51:37 -0600 [thread overview]
Message-ID: <20071207145137.GA4435@sergelap.austin.ibm.com> (raw)
In-Reply-To: <20071206221510.GF10953@fieldses.org>
Quoting J. Bruce Fields (bfields@fieldses.org):
> On Thu, Dec 06, 2007 at 03:57:29PM +0300, Vitaliy Gusev wrote:
> > I am working on pid namespaces vs locks interaction and want to evaluate the
> > idea.
> > fcntl(F_GETLK,..) can return pid of process for not current pid namespace (if
> > process is belonged to the several namespaces). It is true also for pids
> > in /proc/locks. So correct behavior is saving pointer to the struct pid of
> > the process lock owner.
>
> Forgive me, I'm not familiar with pid namespaces. Exactly what bug does
> this patch aim to fix?
When a task is created inside a private pid namespace, it may know
itself as pid 5, while it's "global" pid is 1237. So if it owned a
lock, it would be reported as being owned by 1237.
The patch replaces the pid number, which may signify different tasks in
different namespaces, with the 'struct pid', which uniquely identifies
a task.
> > @@ -673,14 +682,16 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
> > if (posix_locks_conflict(fl, cfl))
> > break;
> > }
> > - if (cfl)
> > + if (cfl) {
> > __locks_copy_lock(fl, cfl);
> > - else
> > + if (cfl->fl_nspid)
> > + fl->fl_pid = pid_nr_ns(cfl->fl_nspid,
> > + task_active_pid_ns(current));
>
> What does pid_nr_ns() do? I took a quick look at the implementation and
> didn't get it.
For the given 'struct pid', which is a unique light-weight task
identifier, it returns the pid number by which it is known in the pid
namespace sent as the second argument. So if a process in the initial
pid namespace queries the process id of task 1237 mentioned above,
pid_nr_ns will return 1237, while a task in the private namespace will
get 5.
> I tend to think that the pid returned by fcntl(.,F_GETLK,.) shouldn't be
> taken too seriously--it may be helpful when debugging--e.g. it might
> help an administrator looking for clues as to who's holding some
> annoying lock. But it probably shouldn't be depended on for the
> correctness of an application. Maybe I'm wrong and there's some reason
> we should worry about it more.
>
> It's also likely to be wrong in the presence of locks held on behalf of
> nfs clients.
Your stance sounds sane. So I'm ok leaving it as is, or doing the hard
work to replace pid_t fl_pid with struct pid fl_pid altogether and
having a separate struct user_flock which has a pid number. The problem
with the patch as it stands is that at any point you now don't know
whether fl_pid is simply unused, is the global pid, or is the pid in a
private namespace. Sounds impossible to maintain.
-serge
next prev parent reply other threads:[~2007-12-07 14:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200712061411.32159.vgusev@openvz.org>
2007-12-06 12:57 ` [RFC][PATCH] Pid namespaces vs locks interaction Vitaliy Gusev
2007-12-06 14:53 ` Serge E. Hallyn
2007-12-06 15:19 ` Vitaliy Gusev
2007-12-06 15:51 ` Serge E. Hallyn
2007-12-08 22:21 ` Brad Boyer
[not found] ` <20071206155130.GA12463-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-12-12 16:07 ` Vitaliy Gusev
2007-12-12 17:31 ` Serge E. Hallyn
[not found] ` <20071212173115.GA21956-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-12-12 17:42 ` Vitaliy Gusev
2007-12-12 18:42 ` Serge E. Hallyn
[not found] ` <20071212184225.GA23504-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-12-13 14:13 ` Vitaliy Gusev
2007-12-13 16:40 ` Serge E. Hallyn
2007-12-06 22:15 ` J. Bruce Fields
2007-12-07 14:51 ` Serge E. Hallyn [this message]
2007-12-21 12:22 ` [PATCH] " Vitaliy Gusev
2007-12-21 14:42 ` Serge E. Hallyn
2007-12-22 0:50 ` Andrew Morton
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=20071207145137.GA4435@sergelap.austin.ibm.com \
--to=serue@us.ibm.com \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=vgusev@openvz.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;
as well as URLs for NNTP newsgroup(s).