diff options
| -rw-r--r-- | fs/nfs/nfs3xdr.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index bffc32406fbf..fa6d72131c19 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c | |||
| @@ -592,13 +592,13 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr) | |||
| 592 | 592 | ||
| 593 | if (attr->ia_valid & ATTR_UID) { | 593 | if (attr->ia_valid & ATTR_UID) { |
| 594 | *p++ = xdr_one; | 594 | *p++ = xdr_one; |
| 595 | *p++ = cpu_to_be32(attr->ia_uid); | 595 | *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid)); |
| 596 | } else | 596 | } else |
| 597 | *p++ = xdr_zero; | 597 | *p++ = xdr_zero; |
| 598 | 598 | ||
| 599 | if (attr->ia_valid & ATTR_GID) { | 599 | if (attr->ia_valid & ATTR_GID) { |
| 600 | *p++ = xdr_one; | 600 | *p++ = xdr_one; |
| 601 | *p++ = cpu_to_be32(attr->ia_gid); | 601 | *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid)); |
| 602 | } else | 602 | } else |
| 603 | *p++ = xdr_zero; | 603 | *p++ = xdr_zero; |
| 604 | 604 | ||
| @@ -657,8 +657,12 @@ static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) | |||
| 657 | 657 | ||
| 658 | fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode; | 658 | fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode; |
| 659 | fattr->nlink = be32_to_cpup(p++); | 659 | fattr->nlink = be32_to_cpup(p++); |
| 660 | fattr->uid = be32_to_cpup(p++); | 660 | fattr->uid = make_kuid(&init_user_ns, be32_to_cpup(p++)); |
| 661 | fattr->gid = be32_to_cpup(p++); | 661 | if (!uid_valid(fattr->uid)) |
| 662 | goto out_uid; | ||
| 663 | fattr->gid = make_kgid(&init_user_ns, be32_to_cpup(p++)); | ||
| 664 | if (!gid_valid(fattr->gid)) | ||
| 665 | goto out_gid; | ||
| 662 | 666 | ||
| 663 | p = xdr_decode_size3(p, &fattr->size); | 667 | p = xdr_decode_size3(p, &fattr->size); |
| 664 | p = xdr_decode_size3(p, &fattr->du.nfs3.used); | 668 | p = xdr_decode_size3(p, &fattr->du.nfs3.used); |
| @@ -675,6 +679,12 @@ static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) | |||
| 675 | 679 | ||
| 676 | fattr->valid |= NFS_ATTR_FATTR_V3; | 680 | fattr->valid |= NFS_ATTR_FATTR_V3; |
| 677 | return 0; | 681 | return 0; |
| 682 | out_uid: | ||
| 683 | dprintk("NFS: returned invalid uid\n"); | ||
| 684 | return -EINVAL; | ||
| 685 | out_gid: | ||
| 686 | dprintk("NFS: returned invalid gid\n"); | ||
| 687 | return -EINVAL; | ||
| 678 | out_overflow: | 688 | out_overflow: |
| 679 | print_overflow_msg(__func__, xdr); | 689 | print_overflow_msg(__func__, xdr); |
| 680 | return -EIO; | 690 | return -EIO; |
