userns: Add a limit on the number of user namespaces

Export the export the maximum number of user namespaces as
/proc/sys/userns/max_user_namespaces.

Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
Eric W. Biederman 2016-08-08 13:41:24 -05:00
parent dbec28460a
commit b376c3e1b6
4 changed files with 81 additions and 11 deletions

View file

@ -44,9 +44,15 @@ struct user_namespace {
struct ctl_table_set set;
struct ctl_table_header *sysctls;
#endif
int max_user_namespaces;
atomic_t user_namespaces;
};
extern struct user_namespace init_user_ns;
extern bool setup_userns_sysctls(struct user_namespace *ns);
extern void retire_userns_sysctls(struct user_namespace *ns);
extern bool inc_user_namespaces(struct user_namespace *ns);
extern void dec_user_namespaces(struct user_namespace *ns);
#ifdef CONFIG_USER_NS