Skip to contentSkip to conversation

userns: Support 9p interacting with multiple user namespaces

RFC PATCH Zhao Hongjiang 2 participants 2 messages Nov 21, 2012 – Nov 22, 2012 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

fs/9p/v9fs.c static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) · line 164

Quoted 12 lines · Eric W. Biederman

From: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>

fs/9p/v9fs.c +1 -1
index d934f04..1c750ab 100644
@@ -161,7 +161,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 				ret = r;
 				continue;
 			}
-			v9ses->dfltuid = option;
+			v9ses->dfltuid = make_kuid(&init_user_ns, option);

I think the init_user_ns should be current_user_ns() cause the value is come from userspace and in kernel we should mapping it to its own user_ns.

Hongjiang

Quoted 10 lines
fs/9p/v9fs.c +6 -0
+			if (!uid_valid(v9ses->dfltuid)) {
+				p9_debug(P9_DEBUG_ERROR,
+					 "uid field, but not a uid?\n");
+				ret = -EINVAL;
+				continue;
+			}
 			break;
 		case Opt_dfltgid:
 			r = match_int(&args[0], &option);

fs/9p/v9fs.c static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) · line 180

Quoted 5 lines
fs/9p/v9fs.c +1 -1
@@ -171,7 +177,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 				ret = r;
 				continue;
 			}
-			v9ses->dfltgid = option;
+			v9ses->dfltgid = make_kgid(&init_user_ns, option);

And this one.

Quoted 21 lines
fs/9p/v9fs.c +8 -1
+			if (!gid_valid(v9ses->dfltgid)) {
+				p9_debug(P9_DEBUG_ERROR,
+					 "gid field, but not a gid?\n");
+				ret = -EINVAL;
+				continue;
+			}
 			break;
 		case Opt_afid:
 			r = match_int(&args[0], &option);
@@ -248,8 +260,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 			else if (strcmp(s, "client") == 0) {
 				v9ses->flags |= V9FS_ACCESS_CLIENT;
 			} else {
+				uid_t uid;
 				v9ses->flags |= V9FS_ACCESS_SINGLE;
-				v9ses->uid = simple_strtoul(s, &e, 10);
+				uid = simple_strtoul(s, &e, 10);
 				if (*e != '\0') {
 					ret = -EINVAL;
 					pr_info("Unknown access argument %s\n",

fs/9p/v9fs.c static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) · line 273

Quoted 4 lines
fs/9p/v9fs.c +1 -0
@@ -257,6 +270,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 					kfree(s);
 					goto free_and_return;
 				}
+				v9ses->uid = make_kuid(&init_user_ns, uid);

Also this one.

fs/9p/v9fs.c static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) · line 282

Quoted 9 lines
fs/9p/v9fs.c +6 -0
+				if (!uid_valid(v9ses->uid)) {
+					ret = -EINVAL;
+					pr_info("Uknown uid %s\n", s);
+					kfree(s);
+					goto free_and_return;
+				}
 			}
 
 			kfree(s);

.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 16 lines · Zhao Hongjiang

fs/9p/v9fs.c static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) · line 164

Quoted 12 lines · Eric W. Biederman

From: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>

fs/9p/v9fs.c +1 -1
index d934f04..1c750ab 100644
@@ -161,7 +161,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
 				ret = r;
 				continue;
 			}
-			v9ses->dfltuid = option;
+			v9ses->dfltuid = make_kuid(&init_user_ns, option);

I think the init_user_ns should be current_user_ns() cause the value is come from userspace and in kernel we should mapping it to its own user_ns.

Good point. current_user_ns() is more appropriate and maintainable.

For now you can only mount 9p when current_user_ns() == &init_user_ns but that might change in the future.

Thanks,
Eric