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 _______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/containers