aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-01 17:22:02 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 09:15:32 -0500
commite5782076e72be2a39bf261f7db03e1769ec05198 (patch)
treeb5815262f6f8cbb9a037fdc2b8f88ef6b35de99d /fs/nfs
parent57a38dae2ac3f3d618bf197314e2805840220d0f (diff)
nfs: Convert nfs4xdr 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. When printing kuids and kgids convert them to values in the initial user namespace then use normal printf formats. 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/nfs4xdr.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 26b143920433..e3edda554ac7 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1002,7 +1002,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
1002 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); 1002 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
1003 if (owner_namelen < 0) { 1003 if (owner_namelen < 0) {
1004 dprintk("nfs: couldn't resolve uid %d to string\n", 1004 dprintk("nfs: couldn't resolve uid %d to string\n",
1005 iap->ia_uid); 1005 from_kuid(&init_user_ns, iap->ia_uid));
1006 /* XXX */ 1006 /* XXX */
1007 strcpy(owner_name, "nobody"); 1007 strcpy(owner_name, "nobody");
1008 owner_namelen = sizeof("nobody") - 1; 1008 owner_namelen = sizeof("nobody") - 1;
@@ -1014,7 +1014,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
1014 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); 1014 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
1015 if (owner_grouplen < 0) { 1015 if (owner_grouplen < 0) {
1016 dprintk("nfs: couldn't resolve gid %d to string\n", 1016 dprintk("nfs: couldn't resolve gid %d to string\n",
1017 iap->ia_gid); 1017 from_kgid(&init_user_ns, iap->ia_gid));
1018 strcpy(owner_group, "nobody"); 1018 strcpy(owner_group, "nobody");
1019 owner_grouplen = sizeof("nobody") - 1; 1019 owner_grouplen = sizeof("nobody") - 1;
1020 /* goto out; */ 1020 /* goto out; */
@@ -3778,14 +3778,14 @@ out_overflow:
3778} 3778}
3779 3779
3780static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, 3780static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3781 const struct nfs_server *server, uint32_t *uid, 3781 const struct nfs_server *server, kuid_t *uid,
3782 struct nfs4_string *owner_name) 3782 struct nfs4_string *owner_name)
3783{ 3783{
3784 uint32_t len; 3784 uint32_t len;
3785 __be32 *p; 3785 __be32 *p;
3786 int ret = 0; 3786 int ret = 0;
3787 3787
3788 *uid = -2; 3788 *uid = make_kuid(&init_user_ns, -2);
3789 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) 3789 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3790 return -EIO; 3790 return -EIO;
3791 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { 3791 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) {
@@ -3813,7 +3813,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3813 __func__, len); 3813 __func__, len);
3814 bitmap[1] &= ~FATTR4_WORD1_OWNER; 3814 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3815 } 3815 }
3816 dprintk("%s: uid=%d\n", __func__, (int)*uid); 3816 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
3817 return ret; 3817 return ret;
3818out_overflow: 3818out_overflow:
3819 print_overflow_msg(__func__, xdr); 3819 print_overflow_msg(__func__, xdr);
@@ -3821,14 +3821,14 @@ out_overflow:
3821} 3821}
3822 3822
3823static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, 3823static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3824 const struct nfs_server *server, uint32_t *gid, 3824 const struct nfs_server *server, kgid_t *gid,
3825 struct nfs4_string *group_name) 3825 struct nfs4_string *group_name)
3826{ 3826{
3827 uint32_t len; 3827 uint32_t len;
3828 __be32 *p; 3828 __be32 *p;
3829 int ret = 0; 3829 int ret = 0;
3830 3830
3831 *gid = -2; 3831 *gid = make_kgid(&init_user_ns, -2);
3832 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) 3832 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
3833 return -EIO; 3833 return -EIO;
3834 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { 3834 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) {
@@ -3856,7 +3856,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3856 __func__, len); 3856 __func__, len);
3857 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; 3857 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
3858 } 3858 }
3859 dprintk("%s: gid=%d\n", __func__, (int)*gid); 3859 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
3860 return ret; 3860 return ret;
3861out_overflow: 3861out_overflow:
3862 print_overflow_msg(__func__, xdr); 3862 print_overflow_msg(__func__, xdr);