diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:18:52 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-15 01:05:32 -0500 |
commit | 45634cd8cb6541523227753944c7417ac3d20f94 (patch) | |
tree | bb54e7acb675feb089b6b7d28d58e94feee71d9d /fs/autofs4/inode.c | |
parent | 8f0d8163b50e01f398b14bcd4dc039ac5ab18d64 (diff) |
userns: Support autofs4 interacing with multiple user namespaces
Use kuid_t and kgid_t in struct autofs_info and struct autofs_wait_queue.
When creating directories and symlinks default the uid and gid of
the mount requester to the global root uid and gid. autofs4_wait
will update these fields when a mount is requested.
When generating autofsv5 packets report the uid and gid of the mount
requestor in user namespace of the process that opened the pipe,
reporting unmapped uids and gids as overflowuid and overflowgid.
In autofs_dev_ioctl_requester return the uid and gid of the last mount
requester converted into the calling processes user namespace. When the
uid or gid don't map return overflowuid and overflowgid as appropriate,
allowing failure to find a mount requester to be distinguished from
failure to map a mount requester.
The uid and gid mount options specifying the user and group of the
root autofs inode are converted into kuid and kgid as they are parsed
defaulting to the current uid and current gid of the process that
mounts autofs.
Mounting of autofs for the present remains confined to processes in
the initial user namespace.
Cc: Ian Kent <raven@themaw.net>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/autofs4/inode.c')
-rw-r--r-- | fs/autofs4/inode.c | 24 |
1 files changed, 15 insertions, 9 deletions
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)) |