diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 18:44:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 18:44:47 -0500 |
commit | 6a2b60b17b3e48a418695a94bd2420f6ab32e519 (patch) | |
tree | 54b7792fa68b8890f710fa6398b6ba8626a039a8 /fs/autofs4 | |
parent | 9228ff90387e276ad67b10c0eb525c9d6a57d5e9 (diff) | |
parent | 98f842e675f96ffac96e6c50315790912b2812be (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace changes from Eric Biederman:
"While small this set of changes is very significant with respect to
containers in general and user namespaces in particular. The user
space interface is now complete.
This set of changes adds support for unprivileged users to create user
namespaces and as a user namespace root to create other namespaces.
The tyranny of supporting suid root preventing unprivileged users from
using cool new kernel features is broken.
This set of changes completes the work on setns, adding support for
the pid, user, mount namespaces.
This set of changes includes a bunch of basic pid namespace
cleanups/simplifications. Of particular significance is the rework of
the pid namespace cleanup so it no longer requires sending out
tendrils into all kinds of unexpected cleanup paths for operation. At
least one case of broken error handling is fixed by this cleanup.
The files under /proc/<pid>/ns/ have been converted from regular files
to magic symlinks which prevents incorrect caching by the VFS,
ensuring the files always refer to the namespace the process is
currently using and ensuring that the ptrace_mayaccess permission
checks are always applied.
The files under /proc/<pid>/ns/ have been given stable inode numbers
so it is now possible to see if different processes share the same
namespaces.
Through the David Miller's net tree are changes to relax many of the
permission checks in the networking stack to allowing the user
namespace root to usefully use the networking stack. Similar changes
for the mount namespace and the pid namespace are coming through my
tree.
Two small changes to add user namespace support were commited here adn
in David Miller's -net tree so that I could complete the work on the
/proc/<pid>/ns/ files in this tree.
Work remains to make it safe to build user namespaces and 9p, afs,
ceph, cifs, coda, gfs2, ncpfs, nfs, nfsd, ocfs2, and xfs so the
Kconfig guard remains in place preventing that user namespaces from
being built when any of those filesystems are enabled.
Future design work remains to allow root users outside of the initial
user namespace to mount more than just /proc and /sys."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (38 commits)
proc: Usable inode numbers for the namespace file descriptors.
proc: Fix the namespace inode permission checks.
proc: Generalize proc inode allocation
userns: Allow unprivilged mounts of proc and sysfs
userns: For /proc/self/{uid,gid}_map derive the lower userns from the struct file
procfs: Print task uids and gids in the userns that opened the proc file
userns: Implement unshare of the user namespace
userns: Implent proc namespace operations
userns: Kill task_user_ns
userns: Make create_new_namespaces take a user_ns parameter
userns: Allow unprivileged use of setns.
userns: Allow unprivileged users to create new namespaces
userns: Allow setting a userns mapping to your current uid.
userns: Allow chown and setgid preservation
userns: Allow unprivileged users to create user namespaces.
userns: Ignore suid and sgid on binaries if the uid or gid can not be mapped
userns: fix return value on mntns_install() failure
vfs: Allow unprivileged manipulation of the mount namespace.
vfs: Only support slave subtrees across different user namespaces
vfs: Add a user namespace reference from struct mnt_namespace
...
Diffstat (limited to 'fs/autofs4')
-rw-r--r-- | fs/autofs4/autofs_i.h | 8 | ||||
-rw-r--r-- | fs/autofs4/dev-ioctl.c | 4 | ||||
-rw-r--r-- | fs/autofs4/inode.c | 24 | ||||
-rw-r--r-- | fs/autofs4/waitq.c | 5 |
4 files changed, 24 insertions, 17 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index 908e18455413..b785e7707959 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h | |||
@@ -74,8 +74,8 @@ struct autofs_info { | |||
74 | unsigned long last_used; | 74 | unsigned long last_used; |
75 | atomic_t count; | 75 | atomic_t count; |
76 | 76 | ||
77 | uid_t uid; | 77 | kuid_t uid; |
78 | gid_t gid; | 78 | kgid_t gid; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ | 81 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ |
@@ -89,8 +89,8 @@ struct autofs_wait_queue { | |||
89 | struct qstr name; | 89 | struct qstr name; |
90 | u32 dev; | 90 | u32 dev; |
91 | u64 ino; | 91 | u64 ino; |
92 | uid_t uid; | 92 | kuid_t uid; |
93 | gid_t gid; | 93 | kgid_t gid; |
94 | pid_t pid; | 94 | pid_t pid; |
95 | pid_t tgid; | 95 | pid_t tgid; |
96 | /* This is for status reporting upon return */ | 96 | /* This is for status reporting upon return */ |
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index a16214109d31..9f68a37bb2b2 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c | |||
@@ -437,8 +437,8 @@ static int autofs_dev_ioctl_requester(struct file *fp, | |||
437 | err = 0; | 437 | err = 0; |
438 | autofs4_expire_wait(path.dentry); | 438 | autofs4_expire_wait(path.dentry); |
439 | spin_lock(&sbi->fs_lock); | 439 | spin_lock(&sbi->fs_lock); |
440 | param->requester.uid = ino->uid; | 440 | param->requester.uid = from_kuid_munged(current_user_ns(), ino->uid); |
441 | param->requester.gid = ino->gid; | 441 | param->requester.gid = from_kgid_munged(current_user_ns(), ino->gid); |
442 | spin_unlock(&sbi->fs_lock); | 442 | spin_unlock(&sbi->fs_lock); |
443 | } | 443 | } |
444 | path_put(&path); | 444 | path_put(&path); |
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 8a4fed8ead30..b104726e2d0a 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -36,8 +36,8 @@ struct autofs_info *autofs4_new_ino(struct autofs_sb_info *sbi) | |||
36 | 36 | ||
37 | void autofs4_clean_ino(struct autofs_info *ino) | 37 | void autofs4_clean_ino(struct autofs_info *ino) |
38 | { | 38 | { |
39 | ino->uid = 0; | 39 | ino->uid = GLOBAL_ROOT_UID; |
40 | ino->gid = 0; | 40 | ino->gid = GLOBAL_ROOT_GID; |
41 | ino->last_used = jiffies; | 41 | ino->last_used = jiffies; |
42 | } | 42 | } |
43 | 43 | ||
@@ -79,10 +79,12 @@ static int autofs4_show_options(struct seq_file *m, struct dentry *root) | |||
79 | return 0; | 79 | return 0; |
80 | 80 | ||
81 | seq_printf(m, ",fd=%d", sbi->pipefd); | 81 | seq_printf(m, ",fd=%d", sbi->pipefd); |
82 | if (root_inode->i_uid != 0) | 82 | if (!uid_eq(root_inode->i_uid, GLOBAL_ROOT_UID)) |
83 | seq_printf(m, ",uid=%u", root_inode->i_uid); | 83 | seq_printf(m, ",uid=%u", |
84 | if (root_inode->i_gid != 0) | 84 | from_kuid_munged(&init_user_ns, root_inode->i_uid)); |
85 | seq_printf(m, ",gid=%u", root_inode->i_gid); | 85 | if (!gid_eq(root_inode->i_gid, GLOBAL_ROOT_GID)) |
86 | seq_printf(m, ",gid=%u", | ||
87 | from_kgid_munged(&init_user_ns, root_inode->i_gid)); | ||
86 | seq_printf(m, ",pgrp=%d", sbi->oz_pgrp); | 88 | seq_printf(m, ",pgrp=%d", sbi->oz_pgrp); |
87 | seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ); | 89 | seq_printf(m, ",timeout=%lu", sbi->exp_timeout/HZ); |
88 | seq_printf(m, ",minproto=%d", sbi->min_proto); | 90 | seq_printf(m, ",minproto=%d", sbi->min_proto); |
@@ -126,7 +128,7 @@ static const match_table_t tokens = { | |||
126 | {Opt_err, NULL} | 128 | {Opt_err, NULL} |
127 | }; | 129 | }; |
128 | 130 | ||
129 | static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, | 131 | static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, |
130 | pid_t *pgrp, unsigned int *type, int *minproto, int *maxproto) | 132 | pid_t *pgrp, unsigned int *type, int *minproto, int *maxproto) |
131 | { | 133 | { |
132 | char *p; | 134 | char *p; |
@@ -159,12 +161,16 @@ static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, | |||
159 | case Opt_uid: | 161 | case Opt_uid: |
160 | if (match_int(args, &option)) | 162 | if (match_int(args, &option)) |
161 | return 1; | 163 | return 1; |
162 | *uid = option; | 164 | *uid = make_kuid(current_user_ns(), option); |
165 | if (!uid_valid(*uid)) | ||
166 | return 1; | ||
163 | break; | 167 | break; |
164 | case Opt_gid: | 168 | case Opt_gid: |
165 | if (match_int(args, &option)) | 169 | if (match_int(args, &option)) |
166 | return 1; | 170 | return 1; |
167 | *gid = option; | 171 | *gid = make_kgid(current_user_ns(), option); |
172 | if (!gid_valid(*gid)) | ||
173 | return 1; | ||
168 | break; | 174 | break; |
169 | case Opt_pgrp: | 175 | case Opt_pgrp: |
170 | if (match_int(args, &option)) | 176 | if (match_int(args, &option)) |
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index dce436e595c1..03bc1d347d8e 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c | |||
@@ -154,6 +154,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi, | |||
154 | case autofs_ptype_expire_direct: | 154 | case autofs_ptype_expire_direct: |
155 | { | 155 | { |
156 | struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet; | 156 | struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet; |
157 | struct user_namespace *user_ns = sbi->pipe->f_cred->user_ns; | ||
157 | 158 | ||
158 | pktsz = sizeof(*packet); | 159 | pktsz = sizeof(*packet); |
159 | 160 | ||
@@ -163,8 +164,8 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi, | |||
163 | packet->name[wq->name.len] = '\0'; | 164 | packet->name[wq->name.len] = '\0'; |
164 | packet->dev = wq->dev; | 165 | packet->dev = wq->dev; |
165 | packet->ino = wq->ino; | 166 | packet->ino = wq->ino; |
166 | packet->uid = wq->uid; | 167 | packet->uid = from_kuid_munged(user_ns, wq->uid); |
167 | packet->gid = wq->gid; | 168 | packet->gid = from_kgid_munged(user_ns, wq->gid); |
168 | packet->pid = wq->pid; | 169 | packet->pid = wq->pid; |
169 | packet->tgid = wq->tgid; | 170 | packet->tgid = wq->tgid; |
170 | break; | 171 | break; |