Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: Convert idmap to use kuids and kgids

Convert nfsd_map_name_to_uid to return a kuid_t value.
Convert nfsd_map_name_to_gid to return a kgid_t value.
Convert nfsd_map_uid_to_name to take a kuid_t parameter.
Convert nfsd_map_gid_to_name to take a kgid_t paramater.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+24 -10
+4 -4
fs/nfsd/idmap.h
··· 54 54 } 55 55 #endif 56 56 57 - __be32 nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *); 58 - __be32 nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, __u32 *); 59 - int nfsd_map_uid_to_name(struct svc_rqst *, __u32, char *); 60 - int nfsd_map_gid_to_name(struct svc_rqst *, __u32, char *); 57 + __be32 nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, kuid_t *); 58 + __be32 nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, kgid_t *); 59 + int nfsd_map_uid_to_name(struct svc_rqst *, kuid_t, char *); 60 + int nfsd_map_gid_to_name(struct svc_rqst *, kgid_t, char *); 61 61 62 62 #endif /* LINUX_NFSD_IDMAP_H */
+20 -6
fs/nfsd/nfs4idmap.c
··· 625 625 626 626 __be32 627 627 nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name, size_t namelen, 628 - __u32 *id) 628 + kuid_t *uid) 629 629 { 630 - return do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, id); 630 + __be32 status; 631 + u32 id = -1; 632 + status = do_name_to_id(rqstp, IDMAP_TYPE_USER, name, namelen, &id); 633 + *uid = make_kuid(&init_user_ns, id); 634 + if (!uid_valid(*uid)) 635 + status = nfserr_badowner; 636 + return status; 631 637 } 632 638 633 639 __be32 634 640 nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name, size_t namelen, 635 - __u32 *id) 641 + kgid_t *gid) 636 642 { 637 - return do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, id); 643 + __be32 status; 644 + u32 id = -1; 645 + status = do_name_to_id(rqstp, IDMAP_TYPE_GROUP, name, namelen, &id); 646 + *gid = make_kgid(&init_user_ns, id); 647 + if (!gid_valid(*gid)) 648 + status = nfserr_badowner; 649 + return status; 638 650 } 639 651 640 652 int 641 - nfsd_map_uid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) 653 + nfsd_map_uid_to_name(struct svc_rqst *rqstp, kuid_t uid, char *name) 642 654 { 655 + u32 id = from_kuid(&init_user_ns, uid); 643 656 return do_id_to_name(rqstp, IDMAP_TYPE_USER, id, name); 644 657 } 645 658 646 659 int 647 - nfsd_map_gid_to_name(struct svc_rqst *rqstp, __u32 id, char *name) 660 + nfsd_map_gid_to_name(struct svc_rqst *rqstp, kgid_t gid, char *name) 648 661 { 662 + u32 id = from_kgid(&init_user_ns, gid); 649 663 return do_id_to_name(rqstp, IDMAP_TYPE_GROUP, id, name); 650 664 }