[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1239735211.32604.107.camel@nimitz>
Date: Tue, 14 Apr 2009 11:53:31 -0700
From: Dave Hansen <dave@...ux.vnet.ibm.com>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: akpm@...ux-foundation.org, containers@...ts.linux-foundation.org,
xemul@...allels.com, serue@...ibm.com, mingo@...e.hu,
orenl@...columbia.edu, hch@...radead.org,
torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 26/30] cr: mount namespace
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
--
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