mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
nfsd: Convert nfsxdr to use kuids and kgids
When reading uids and gids off the wire convert them to kuids and kgids. If the conversion results in an invalid result don't set the ATTR_UID or ATTR_GID. 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>
This commit is contained in:
parent
458878a705
commit
7c19723e99
1 changed files with 8 additions and 6 deletions
|
@ -100,12 +100,14 @@ decode_sattr(__be32 *p, struct iattr *iap)
|
||||||
iap->ia_mode = tmp;
|
iap->ia_mode = tmp;
|
||||||
}
|
}
|
||||||
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
||||||
iap->ia_valid |= ATTR_UID;
|
iap->ia_uid = make_kuid(&init_user_ns, tmp);
|
||||||
iap->ia_uid = tmp;
|
if (uid_valid(iap->ia_uid))
|
||||||
|
iap->ia_valid |= ATTR_UID;
|
||||||
}
|
}
|
||||||
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
||||||
iap->ia_valid |= ATTR_GID;
|
iap->ia_gid = make_kgid(&init_user_ns, tmp);
|
||||||
iap->ia_gid = tmp;
|
if (gid_valid(iap->ia_gid))
|
||||||
|
iap->ia_valid |= ATTR_GID;
|
||||||
}
|
}
|
||||||
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
if ((tmp = ntohl(*p++)) != (u32)-1) {
|
||||||
iap->ia_valid |= ATTR_SIZE;
|
iap->ia_valid |= ATTR_SIZE;
|
||||||
|
@ -151,8 +153,8 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
|
||||||
*p++ = htonl(nfs_ftypes[type >> 12]);
|
*p++ = htonl(nfs_ftypes[type >> 12]);
|
||||||
*p++ = htonl((u32) stat->mode);
|
*p++ = htonl((u32) stat->mode);
|
||||||
*p++ = htonl((u32) stat->nlink);
|
*p++ = htonl((u32) stat->nlink);
|
||||||
*p++ = htonl((u32) stat->uid);
|
*p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
|
||||||
*p++ = htonl((u32) stat->gid);
|
*p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
|
||||||
|
|
||||||
if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
|
if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
|
||||||
*p++ = htonl(NFS_MAXPATHLEN);
|
*p++ = htonl(NFS_MAXPATHLEN);
|
||||||
|
|
Loading…
Reference in a new issue