@@ -149,6 +149,11 @@ static const char *proc_namespaces_getlink(struct dentry *dentry,
ns = get_namespace_by_dentry(pid_ns, dentry);
if (!ns)
goto out;
+ ret = -ESRCH;
+ if (ns->ops->can_get && !ns->ops->can_get(ns)) {
+ ns->ops->put(ns);
+ goto out;
+ }
ret = __ns_get_path(&path, ns);
if (ret == -EAGAIN)
@@ -19,6 +19,7 @@ struct proc_ns_operations {
int type;
struct ns_common *(*get)(struct task_struct *task);
void (*put)(struct ns_common *ns);
+ bool (*can_get)(struct ns_common *ns);
int (*install)(struct nsset *nsset, struct ns_common *ns);
struct user_namespace *(*owner)(struct ns_common *ns);
struct ns_common *(*get_parent)(struct ns_common *ns);
@@ -452,6 +452,7 @@ const struct proc_ns_operations pidns_for_children_operations = {
.real_ns_name = "pid",
.type = CLONE_NEWPID,
.get = pidns_for_children_get,
+ .can_get = pidns_can_get,
.put = pidns_put,
.install = pidns_install,
.owner = pidns_owner,
This is a new method to prohibit some namespaces in intermediate state. Currently, it's used to prohibit pid namespace, whose child reaper is not created yet (similar to we have in /proc/[pid]/pid_for_children). Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> --- fs/proc/namespaces.c | 5 +++++ include/linux/proc_ns.h | 1 + kernel/pid_namespace.c | 1 + 3 files changed, 7 insertions(+)