]> Pileus Git - ~andy/linux/commitdiff
nfs: Convert nfs4xdr to use kuids and kgids
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 1 Feb 2013 22:22:02 +0000 (14:22 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 13 Feb 2013 14:15:32 +0000 (06:15 -0800)
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>
fs/nfs/nfs4xdr.c

index 26b143920433e628456476e0d1b708b8fc395d43..e3edda554ac7f4e17da3a6e115df1b1797d63efd 100644 (file)
@@ -1002,7 +1002,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
                owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
                if (owner_namelen < 0) {
                        dprintk("nfs: couldn't resolve uid %d to string\n",
-                                       iap->ia_uid);
+                                       from_kuid(&init_user_ns, iap->ia_uid));
                        /* XXX */
                        strcpy(owner_name, "nobody");
                        owner_namelen = sizeof("nobody") - 1;
@@ -1014,7 +1014,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
                owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
                if (owner_grouplen < 0) {
                        dprintk("nfs: couldn't resolve gid %d to string\n",
-                                       iap->ia_gid);
+                                       from_kgid(&init_user_ns, iap->ia_gid));
                        strcpy(owner_group, "nobody");
                        owner_grouplen = sizeof("nobody") - 1;
                        /* goto out; */
@@ -3778,14 +3778,14 @@ out_overflow:
 }
 
 static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
-               const struct nfs_server *server, uint32_t *uid,
+               const struct nfs_server *server, kuid_t *uid,
                struct nfs4_string *owner_name)
 {
        uint32_t len;
        __be32 *p;
        int ret = 0;
 
-       *uid = -2;
+       *uid = make_kuid(&init_user_ns, -2);
        if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
                return -EIO;
        if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) {
@@ -3813,7 +3813,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
                                        __func__, len);
                bitmap[1] &= ~FATTR4_WORD1_OWNER;
        }
-       dprintk("%s: uid=%d\n", __func__, (int)*uid);
+       dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
        return ret;
 out_overflow:
        print_overflow_msg(__func__, xdr);
@@ -3821,14 +3821,14 @@ out_overflow:
 }
 
 static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
-               const struct nfs_server *server, uint32_t *gid,
+               const struct nfs_server *server, kgid_t *gid,
                struct nfs4_string *group_name)
 {
        uint32_t len;
        __be32 *p;
        int ret = 0;
 
-       *gid = -2;
+       *gid = make_kgid(&init_user_ns, -2);
        if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
                return -EIO;
        if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) {
@@ -3856,7 +3856,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
                                        __func__, len);
                bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
        }
-       dprintk("%s: gid=%d\n", __func__, (int)*gid);
+       dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
        return ret;
 out_overflow:
        print_overflow_msg(__func__, xdr);