aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/protocol.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-25 19:00:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-25 19:00:49 -0500
commit94f2f14234178f118545a0be60a6371ddeb229b7 (patch)
tree313af6e9e255e9060fc24c836cd71ce712502b17 /net/9p/protocol.c
parent8d168f71551ec2a6528d01d0389b7a73c091e3e7 (diff)
parent139321c65c0584cd65c4c87a5eb3fdb4fdbd0e19 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace and namespace infrastructure changes from Eric W Biederman: "This set of changes starts with a few small enhnacements to the user namespace. reboot support, allowing more arbitrary mappings, and support for mounting devpts, ramfs, tmpfs, and mqueuefs as just the user namespace root. I do my best to document that if you care about limiting your unprivileged users that when you have the user namespace support enabled you will need to enable memory control groups. There is a minor bug fix to prevent overflowing the stack if someone creates way too many user namespaces. The bulk of the changes are a continuation of the kuid/kgid push down work through the filesystems. These changes make using uids and gids typesafe which ensures that these filesystems are safe to use when multiple user namespaces are in use. The filesystems converted for 3.9 are ceph, 9p, afs, ocfs2, gfs2, ncpfs, nfs, nfsd, and cifs. The changes for these filesystems were a little more involved so I split the changes into smaller hopefully obviously correct changes. XFS is the only filesystem that remains. I was hoping I could get that in this release so that user namespace support would be enabled with an allyesconfig or an allmodconfig but it looks like the xfs changes need another couple of days before it they are ready." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (93 commits) cifs: Enable building with user namespaces enabled. cifs: Convert struct cifs_ses to use a kuid_t and a kgid_t cifs: Convert struct cifs_sb_info to use kuids and kgids cifs: Modify struct smb_vol to use kuids and kgids cifs: Convert struct cifsFileInfo to use a kuid cifs: Convert struct cifs_fattr to use kuid and kgids cifs: Convert struct tcon_link to use a kuid. cifs: Modify struct cifs_unix_set_info_args to hold a kuid_t and a kgid_t cifs: Convert from a kuid before printing current_fsuid cifs: Use kuids and kgids SID to uid/gid mapping cifs: Pass GLOBAL_ROOT_UID and GLOBAL_ROOT_GID to keyring_alloc cifs: Use BUILD_BUG_ON to validate uids and gids are the same size cifs: Override unmappable incoming uids and gids nfsd: Enable building with user namespaces enabled. nfsd: Properly compare and initialize kuids and kgids nfsd: Store ex_anon_uid and ex_anon_gid as kuids and kgids nfsd: Modify nfsd4_cb_sec to use kuids and kgids nfsd: Handle kuids and kgids in the nfs4acl to posix_acl conversion nfsd: Convert nfsxdr to use kuids and kgids nfsd: Convert nfs3xdr to use kuids and kgids ...
Diffstat (limited to 'net/9p/protocol.c')
-rw-r--r--net/9p/protocol.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index 3d33ecf13327..ab9127ec5b7a 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -85,6 +85,8 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
85 d - int32_t 85 d - int32_t
86 q - int64_t 86 q - int64_t
87 s - string 87 s - string
88 u - numeric uid
89 g - numeric gid
88 S - stat 90 S - stat
89 Q - qid 91 Q - qid
90 D - data blob (int32_t size followed by void *, results are not freed) 92 D - data blob (int32_t size followed by void *, results are not freed)
@@ -163,6 +165,26 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
163 (*sptr)[len] = 0; 165 (*sptr)[len] = 0;
164 } 166 }
165 break; 167 break;
168 case 'u': {
169 kuid_t *uid = va_arg(ap, kuid_t *);
170 __le32 le_val;
171 if (pdu_read(pdu, &le_val, sizeof(le_val))) {
172 errcode = -EFAULT;
173 break;
174 }
175 *uid = make_kuid(&init_user_ns,
176 le32_to_cpu(le_val));
177 } break;
178 case 'g': {
179 kgid_t *gid = va_arg(ap, kgid_t *);
180 __le32 le_val;
181 if (pdu_read(pdu, &le_val, sizeof(le_val))) {
182 errcode = -EFAULT;
183 break;
184 }
185 *gid = make_kgid(&init_user_ns,
186 le32_to_cpu(le_val));
187 } break;
166 case 'Q':{ 188 case 'Q':{
167 struct p9_qid *qid = 189 struct p9_qid *qid =
168 va_arg(ap, struct p9_qid *); 190 va_arg(ap, struct p9_qid *);
@@ -177,11 +199,12 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
177 va_arg(ap, struct p9_wstat *); 199 va_arg(ap, struct p9_wstat *);
178 200
179 memset(stbuf, 0, sizeof(struct p9_wstat)); 201 memset(stbuf, 0, sizeof(struct p9_wstat));
180 stbuf->n_uid = stbuf->n_gid = stbuf->n_muid = 202 stbuf->n_uid = stbuf->n_muid = INVALID_UID;
181 -1; 203 stbuf->n_gid = INVALID_GID;
204
182 errcode = 205 errcode =
183 p9pdu_readf(pdu, proto_version, 206 p9pdu_readf(pdu, proto_version,
184 "wwdQdddqssss?sddd", 207 "wwdQdddqssss?sugu",
185 &stbuf->size, &stbuf->type, 208 &stbuf->size, &stbuf->type,
186 &stbuf->dev, &stbuf->qid, 209 &stbuf->dev, &stbuf->qid,
187 &stbuf->mode, &stbuf->atime, 210 &stbuf->mode, &stbuf->atime,
@@ -294,7 +317,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
294 memset(stbuf, 0, sizeof(struct p9_stat_dotl)); 317 memset(stbuf, 0, sizeof(struct p9_stat_dotl));
295 errcode = 318 errcode =
296 p9pdu_readf(pdu, proto_version, 319 p9pdu_readf(pdu, proto_version,
297 "qQdddqqqqqqqqqqqqqqq", 320 "qQdugqqqqqqqqqqqqqqq",
298 &stbuf->st_result_mask, 321 &stbuf->st_result_mask,
299 &stbuf->qid, 322 &stbuf->qid,
300 &stbuf->st_mode, 323 &stbuf->st_mode,
@@ -377,6 +400,20 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
377 errcode = -EFAULT; 400 errcode = -EFAULT;
378 } 401 }
379 break; 402 break;
403 case 'u': {
404 kuid_t uid = va_arg(ap, kuid_t);
405 __le32 val = cpu_to_le32(
406 from_kuid(&init_user_ns, uid));
407 if (pdu_write(pdu, &val, sizeof(val)))
408 errcode = -EFAULT;
409 } break;
410 case 'g': {
411 kgid_t gid = va_arg(ap, kgid_t);
412 __le32 val = cpu_to_le32(
413 from_kgid(&init_user_ns, gid));
414 if (pdu_write(pdu, &val, sizeof(val)))
415 errcode = -EFAULT;
416 } break;
380 case 'Q':{ 417 case 'Q':{
381 const struct p9_qid *qid = 418 const struct p9_qid *qid =
382 va_arg(ap, const struct p9_qid *); 419 va_arg(ap, const struct p9_qid *);
@@ -390,7 +427,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
390 va_arg(ap, const struct p9_wstat *); 427 va_arg(ap, const struct p9_wstat *);
391 errcode = 428 errcode =
392 p9pdu_writef(pdu, proto_version, 429 p9pdu_writef(pdu, proto_version,
393 "wwdQdddqssss?sddd", 430 "wwdQdddqssss?sugu",
394 stbuf->size, stbuf->type, 431 stbuf->size, stbuf->type,
395 stbuf->dev, &stbuf->qid, 432 stbuf->dev, &stbuf->qid,
396 stbuf->mode, stbuf->atime, 433 stbuf->mode, stbuf->atime,
@@ -468,7 +505,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
468 struct p9_iattr_dotl *); 505 struct p9_iattr_dotl *);
469 506
470 errcode = p9pdu_writef(pdu, proto_version, 507 errcode = p9pdu_writef(pdu, proto_version,
471 "ddddqqqqq", 508 "ddugqqqqq",
472 p9attr->valid, 509 p9attr->valid,
473 p9attr->mode, 510 p9attr->mode,
474 p9attr->uid, 511 p9attr->uid,