aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-02 07:16:08 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 09:16:04 -0500
commit458878a705c822a6be267977e435b16576bde59b (patch)
tree95d2272183c41cd999eda74b9f90c16f46533105
parente097258f2eb4a91e7389ae69a3c87df111637a3f (diff)
nfsd: Convert nfs3xdr 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. Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--fs/nfsd/nfs3xdr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 1884a3fbb584..925c944bc0bc 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -105,12 +105,14 @@ decode_sattr3(__be32 *p, struct iattr *iap)
105 iap->ia_mode = ntohl(*p++); 105 iap->ia_mode = ntohl(*p++);
106 } 106 }
107 if (*p++) { 107 if (*p++) {
108 iap->ia_valid |= ATTR_UID; 108 iap->ia_uid = make_kuid(&init_user_ns, ntohl(*p++));
109 iap->ia_uid = ntohl(*p++); 109 if (uid_valid(iap->ia_uid))
110 iap->ia_valid |= ATTR_UID;
110 } 111 }
111 if (*p++) { 112 if (*p++) {
112 iap->ia_valid |= ATTR_GID; 113 iap->ia_gid = make_kgid(&init_user_ns, ntohl(*p++));
113 iap->ia_gid = ntohl(*p++); 114 if (gid_valid(iap->ia_gid))
115 iap->ia_valid |= ATTR_GID;
114 } 116 }
115 if (*p++) { 117 if (*p++) {
116 u64 newsize; 118 u64 newsize;
@@ -167,8 +169,8 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
167 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); 169 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
168 *p++ = htonl((u32) stat->mode); 170 *p++ = htonl((u32) stat->mode);
169 *p++ = htonl((u32) stat->nlink); 171 *p++ = htonl((u32) stat->nlink);
170 *p++ = htonl((u32) stat->uid); 172 *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
171 *p++ = htonl((u32) stat->gid); 173 *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
172 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) { 174 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
173 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); 175 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
174 } else { 176 } else {