aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-01-30 14:57:40 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-12 06:19:33 -0500
commit76ed23a5d703d94ede1ef6c12c14a75add691202 (patch)
tree535c8cca578b3284611ad1375f0c352aaceca4fa /fs/9p
parentb464255699077c6b33ea58ee01db80f5729511ad (diff)
9p: Modify struct v9fs_session_info to use a kuids and kgids
Change struct v9fs_session_info and the code that popluates it to use kuids and kgids. When parsing the 9p mount options convert the dfltuid, dflutgid, and the session uid from the current user namespace into kuids and kgids. Modify V9FS_DEFUID and V9FS_DEFGUID to be kuid and kgid values. Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@gmail.com> Cc: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/v9fs.c30
-rw-r--r--fs/9p/v9fs.h10
2 files changed, 30 insertions, 10 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index d64967cbd73e..58e6cbce4156 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -161,7 +161,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
161 ret = r; 161 ret = r;
162 continue; 162 continue;
163 } 163 }
164 v9ses->dfltuid = option; 164 v9ses->dfltuid = make_kuid(current_user_ns(), option);
165 if (!uid_valid(v9ses->dfltuid)) {
166 p9_debug(P9_DEBUG_ERROR,
167 "uid field, but not a uid?\n");
168 ret = -EINVAL;
169 continue;
170 }
165 break; 171 break;
166 case Opt_dfltgid: 172 case Opt_dfltgid:
167 r = match_int(&args[0], &option); 173 r = match_int(&args[0], &option);
@@ -171,7 +177,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
171 ret = r; 177 ret = r;
172 continue; 178 continue;
173 } 179 }
174 v9ses->dfltgid = option; 180 v9ses->dfltgid = make_kgid(current_user_ns(), option);
181 if (!gid_valid(v9ses->dfltgid)) {
182 p9_debug(P9_DEBUG_ERROR,
183 "gid field, but not a gid?\n");
184 ret = -EINVAL;
185 continue;
186 }
175 break; 187 break;
176 case Opt_afid: 188 case Opt_afid:
177 r = match_int(&args[0], &option); 189 r = match_int(&args[0], &option);
@@ -248,8 +260,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
248 else if (strcmp(s, "client") == 0) { 260 else if (strcmp(s, "client") == 0) {
249 v9ses->flags |= V9FS_ACCESS_CLIENT; 261 v9ses->flags |= V9FS_ACCESS_CLIENT;
250 } else { 262 } else {
263 uid_t uid;
251 v9ses->flags |= V9FS_ACCESS_SINGLE; 264 v9ses->flags |= V9FS_ACCESS_SINGLE;
252 v9ses->uid = simple_strtoul(s, &e, 10); 265 uid = simple_strtoul(s, &e, 10);
253 if (*e != '\0') { 266 if (*e != '\0') {
254 ret = -EINVAL; 267 ret = -EINVAL;
255 pr_info("Unknown access argument %s\n", 268 pr_info("Unknown access argument %s\n",
@@ -257,6 +270,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
257 kfree(s); 270 kfree(s);
258 goto free_and_return; 271 goto free_and_return;
259 } 272 }
273 v9ses->uid = make_kuid(current_user_ns(), uid);
274 if (!uid_valid(v9ses->uid)) {
275 ret = -EINVAL;
276 pr_info("Uknown uid %s\n", s);
277 kfree(s);
278 goto free_and_return;
279 }
260 } 280 }
261 281
262 kfree(s); 282 kfree(s);
@@ -319,7 +339,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
319 list_add(&v9ses->slist, &v9fs_sessionlist); 339 list_add(&v9ses->slist, &v9fs_sessionlist);
320 spin_unlock(&v9fs_sessionlist_lock); 340 spin_unlock(&v9fs_sessionlist_lock);
321 341
322 v9ses->uid = ~0; 342 v9ses->uid = INVALID_UID;
323 v9ses->dfltuid = V9FS_DEFUID; 343 v9ses->dfltuid = V9FS_DEFUID;
324 v9ses->dfltgid = V9FS_DEFGID; 344 v9ses->dfltgid = V9FS_DEFGID;
325 345
@@ -364,7 +384,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
364 384
365 v9ses->flags &= ~V9FS_ACCESS_MASK; 385 v9ses->flags &= ~V9FS_ACCESS_MASK;
366 v9ses->flags |= V9FS_ACCESS_ANY; 386 v9ses->flags |= V9FS_ACCESS_ANY;
367 v9ses->uid = ~0; 387 v9ses->uid = INVALID_UID;
368 } 388 }
369 if (!v9fs_proto_dotl(v9ses) || 389 if (!v9fs_proto_dotl(v9ses) ||
370 !((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) { 390 !((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_CLIENT)) {
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 34c59f14a1c9..a8e127c89627 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -109,9 +109,9 @@ struct v9fs_session_info {
109 char *uname; /* user name to mount as */ 109 char *uname; /* user name to mount as */
110 char *aname; /* name of remote hierarchy being mounted */ 110 char *aname; /* name of remote hierarchy being mounted */
111 unsigned int maxdata; /* max data for client interface */ 111 unsigned int maxdata; /* max data for client interface */
112 unsigned int dfltuid; /* default uid/muid for legacy support */ 112 kuid_t dfltuid; /* default uid/muid for legacy support */
113 unsigned int dfltgid; /* default gid for legacy support */ 113 kgid_t dfltgid; /* default gid for legacy support */
114 u32 uid; /* if ACCESS_SINGLE, the uid that has access */ 114 kuid_t uid; /* if ACCESS_SINGLE, the uid that has access */
115 struct p9_client *clnt; /* 9p client */ 115 struct p9_client *clnt; /* 9p client */
116 struct list_head slist; /* list of sessions registered with v9fs */ 116 struct list_head slist; /* list of sessions registered with v9fs */
117 struct backing_dev_info bdi; 117 struct backing_dev_info bdi;
@@ -165,8 +165,8 @@ extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses,
165#define V9FS_PORT 564 165#define V9FS_PORT 564
166#define V9FS_DEFUSER "nobody" 166#define V9FS_DEFUSER "nobody"
167#define V9FS_DEFANAME "" 167#define V9FS_DEFANAME ""
168#define V9FS_DEFUID (-2) 168#define V9FS_DEFUID KUIDT_INIT(-2)
169#define V9FS_DEFGID (-2) 169#define V9FS_DEFGID KGIDT_INIT(-2)
170 170
171static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode) 171static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
172{ 172{