From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, containers@lists.linux-foundation.org,
xemul@parallels.com, serue@us.ibm.com, mingo@elte.hu,
orenl@cs.columbia.edu, hch@infradead.org,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 26/30] cr: mount namespace
Date: Tue, 14 Apr 2009 11:53:31 -0700 [thread overview]
Message-ID: <1239735211.32604.107.camel@nimitz> (raw)
In-Reply-To: <20090410024004.GA27788@x200.localdomain>
On Fri, 2009-04-10 at 06:40 +0400, Alexey Dobriyan wrote:
> +int cr_collect_all_mnt_ns(struct cr_context *ctx)
> +{
> + struct cr_object *obj;
> + int rv;
> +
> + for_each_cr_object(ctx, obj, CR_CTX_NSPROXY) {
> + struct nsproxy *nsproxy = obj->o_obj;
> +
> + rv = cr_collect_mnt_ns(ctx, nsproxy->mnt_ns);
> + if (rv < 0)
> + return rv;
> + }
> + for_each_cr_object(ctx, obj, CR_CTX_MNT_NS) {
> + struct mnt_namespace *mnt_ns = obj->o_obj;
> + unsigned int cnt = atomic_read(&mnt_ns->count);
> +
> + if (obj->o_count != cnt) {
> + printk("%s: mnt_ns %p has external references %lu:%u\n", __func__, mnt_ns, obj->o_count, cnt);
> + return -EINVAL;
> + }
> + }
> + return 0;
> +}
I worry about depending on refcounts like this, especially when
userspace has an interface that can elevate them. If someone is holding
open /proc/$pid/mounts, this will get elevated and trip the check. This
check is also naturally racy. You check once if there are references,
but there is no locking to keep new references from coming in.
That said, I do like how this for_each_cr_object() stuff looks. It's
pretty clean.
-- Dave
prev parent reply other threads:[~2009-04-14 18:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-10 2:40 [PATCH 26/30] cr: mount namespace Alexey Dobriyan
2009-04-14 18:48 ` Dave Hansen
2009-04-14 18:53 ` Dave Hansen [this message]
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=1239735211.32604.107.camel@nimitz \
--to=dave@linux.vnet.ibm.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=orenl@cs.columbia.edu \
--cc=serue@us.ibm.com \
--cc=torvalds@linux-foundation.org \
--cc=xemul@parallels.com \
/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