aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/user_namespace.h
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2014-12-02 13:27:26 -0500
committerEric W. Biederman <ebiederm@xmission.com>2014-12-11 19:06:36 -0500
commit9cc46516ddf497ea16e8d7cb986ae03a0f6b92f8 (patch)
treed996dd9c6d422e723af0da786add936bd7ec1c91 /include/linux/user_namespace.h
parentf0d62aec931e4ae3333c797d346dc4f188f454ba (diff)
userns: Add a knob to disable setgroups on a per user namespace basis
- Expose the knob to user space through a proc file /proc/<pid>/setgroups A value of "deny" means the setgroups system call is disabled in the current processes user namespace and can not be enabled in the future in this user namespace. A value of "allow" means the segtoups system call is enabled. - Descendant user namespaces inherit the value of setgroups from their parents. - A proc file is used (instead of a sysctl) as sysctls currently do not allow checking the permissions at open time. - Writing to the proc file is restricted to before the gid_map for the user namespace is set. This ensures that disabling setgroups at a user namespace level will never remove the ability to call setgroups from a process that already has that ability. A process may opt in to the setgroups disable for itself by creating, entering and configuring a user namespace or by calling setns on an existing user namespace with setgroups disabled. Processes without privileges already can not call setgroups so this is a noop. Prodcess with privilege become processes without privilege when entering a user namespace and as with any other path to dropping privilege they would not have the ability to call setgroups. So this remains within the bounds of what is possible without a knob to disable setgroups permanently in a user namespace. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'include/linux/user_namespace.h')
-rw-r--r--include/linux/user_namespace.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 8d493083486a..9f3579ff543d 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -17,6 +17,10 @@ struct uid_gid_map { /* 64 bytes -- 1 cache line */
17 } extent[UID_GID_MAP_MAX_EXTENTS]; 17 } extent[UID_GID_MAP_MAX_EXTENTS];
18}; 18};
19 19
20#define USERNS_SETGROUPS_ALLOWED 1UL
21
22#define USERNS_INIT_FLAGS USERNS_SETGROUPS_ALLOWED
23
20struct user_namespace { 24struct user_namespace {
21 struct uid_gid_map uid_map; 25 struct uid_gid_map uid_map;
22 struct uid_gid_map gid_map; 26 struct uid_gid_map gid_map;
@@ -27,6 +31,7 @@ struct user_namespace {
27 kuid_t owner; 31 kuid_t owner;
28 kgid_t group; 32 kgid_t group;
29 unsigned int proc_inum; 33 unsigned int proc_inum;
34 unsigned long flags;
30 35
31 /* Register of per-UID persistent keyrings for this namespace */ 36 /* Register of per-UID persistent keyrings for this namespace */
32#ifdef CONFIG_PERSISTENT_KEYRINGS 37#ifdef CONFIG_PERSISTENT_KEYRINGS
@@ -63,6 +68,8 @@ extern const struct seq_operations proc_projid_seq_operations;
63extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *); 68extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
64extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *); 69extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
65extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *); 70extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
71extern ssize_t proc_setgroups_write(struct file *, const char __user *, size_t, loff_t *);
72extern int proc_setgroups_show(struct seq_file *m, void *v);
66extern bool userns_may_setgroups(const struct user_namespace *ns); 73extern bool userns_may_setgroups(const struct user_namespace *ns);
67#else 74#else
68 75