diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-01 06:45:54 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:30 -0500 |
commit | cfa0898d4ff1874b86d21768adb49d2c033fa90b (patch) | |
tree | c8e0b3fb4d7fb83141e41a2c1a59a0dbea685013 /fs/nfs | |
parent | 9f309c86cf343c59c79d25d9bde5d4a895d2e81f (diff) |
nfs: Convert nfs2xdr to use kuids and kgids
When reading uids and gids off the wire convert them to
kuids and kgids.
When putting kuids and kgids onto the wire first convert
them to uids and gids the other side will understand.
Add an additional failure mode for incoming uid or
gids that are invalid.
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs2xdr.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index 06b9df49f7f7..62db136339ea 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c | |||
@@ -290,8 +290,13 @@ static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) | |||
290 | 290 | ||
291 | fattr->mode = be32_to_cpup(p++); | 291 | fattr->mode = be32_to_cpup(p++); |
292 | fattr->nlink = be32_to_cpup(p++); | 292 | fattr->nlink = be32_to_cpup(p++); |
293 | fattr->uid = be32_to_cpup(p++); | 293 | fattr->uid = make_kuid(&init_user_ns, be32_to_cpup(p++)); |
294 | fattr->gid = be32_to_cpup(p++); | 294 | if (!uid_valid(fattr->uid)) |
295 | goto out_uid; | ||
296 | fattr->gid = make_kgid(&init_user_ns, be32_to_cpup(p++)); | ||
297 | if (!gid_valid(fattr->gid)) | ||
298 | goto out_gid; | ||
299 | |||
295 | fattr->size = be32_to_cpup(p++); | 300 | fattr->size = be32_to_cpup(p++); |
296 | fattr->du.nfs2.blocksize = be32_to_cpup(p++); | 301 | fattr->du.nfs2.blocksize = be32_to_cpup(p++); |
297 | 302 | ||
@@ -313,6 +318,12 @@ static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) | |||
313 | fattr->change_attr = nfs_timespec_to_change_attr(&fattr->ctime); | 318 | fattr->change_attr = nfs_timespec_to_change_attr(&fattr->ctime); |
314 | 319 | ||
315 | return 0; | 320 | return 0; |
321 | out_uid: | ||
322 | dprintk("NFS: returned invalid uid\n"); | ||
323 | return -EINVAL; | ||
324 | out_gid: | ||
325 | dprintk("NFS: returned invalid gid\n"); | ||
326 | return -EINVAL; | ||
316 | out_overflow: | 327 | out_overflow: |
317 | print_overflow_msg(__func__, xdr); | 328 | print_overflow_msg(__func__, xdr); |
318 | return -EIO; | 329 | return -EIO; |
@@ -351,11 +362,11 @@ static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr) | |||
351 | else | 362 | else |
352 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); | 363 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
353 | if (attr->ia_valid & ATTR_UID) | 364 | if (attr->ia_valid & ATTR_UID) |
354 | *p++ = cpu_to_be32(attr->ia_uid); | 365 | *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid)); |
355 | else | 366 | else |
356 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); | 367 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
357 | if (attr->ia_valid & ATTR_GID) | 368 | if (attr->ia_valid & ATTR_GID) |
358 | *p++ = cpu_to_be32(attr->ia_gid); | 369 | *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid)); |
359 | else | 370 | else |
360 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); | 371 | *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET); |
361 | if (attr->ia_valid & ATTR_SIZE) | 372 | if (attr->ia_valid & ATTR_SIZE) |