]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
nfsd: Store ex_anon_uid and ex_anon_gid as kuids and kgids
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 2 Feb 2013 14:42:53 +0000 (06:42 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 13 Feb 2013 14:16:08 +0000 (06:16 -0800)
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/nfsd/auth.c
fs/nfsd/export.c
include/linux/nfsd/export.h

index 34a10d78b839f4c73b3d851e19820bc712129f36..4d6642b38eae7c1138079be2989ff8bc13740f5f 100644 (file)
@@ -58,7 +58,7 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
 
                for (i = 0; i < rqgi->ngroups; i++) {
                        if (gid_eq(GLOBAL_ROOT_GID, GROUP_AT(rqgi, i)))
-                               GROUP_AT(gi, i) = make_kgid(&init_user_ns, exp->ex_anon_gid);
+                               GROUP_AT(gi, i) = exp->ex_anon_gid;
                        else
                                GROUP_AT(gi, i) = GROUP_AT(rqgi, i);
                }
index a3946cf13fc8373d6234c64d4316505364914ca3..5681c5906f088a49d0925ab9c70efc85c2ddc0b0 100644 (file)
@@ -544,13 +544,17 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
                err = get_int(&mesg, &an_int);
                if (err)
                        goto out3;
-               exp.ex_anon_uid= an_int;
+               exp.ex_anon_uid= make_kuid(&init_user_ns, an_int);
+               if (!uid_valid(exp.ex_anon_uid))
+                       goto out3;
 
                /* anon gid */
                err = get_int(&mesg, &an_int);
                if (err)
                        goto out3;
-               exp.ex_anon_gid= an_int;
+               exp.ex_anon_gid= make_kgid(&init_user_ns, an_int);
+               if (!gid_valid(exp.ex_anon_gid))
+                       goto out3;
 
                /* fsid */
                err = get_int(&mesg, &an_int);
@@ -613,7 +617,7 @@ out:
 }
 
 static void exp_flags(struct seq_file *m, int flag, int fsid,
-               uid_t anonu, uid_t anong, struct nfsd4_fs_locations *fslocs);
+               kuid_t anonu, kgid_t anong, struct nfsd4_fs_locations *fslocs);
 static void show_secinfo(struct seq_file *m, struct svc_export *exp);
 
 static int svc_export_show(struct seq_file *m,
@@ -1179,15 +1183,17 @@ static void show_secinfo(struct seq_file *m, struct svc_export *exp)
 }
 
 static void exp_flags(struct seq_file *m, int flag, int fsid,
-               uid_t anonu, uid_t anong, struct nfsd4_fs_locations *fsloc)
+               kuid_t anonu, kgid_t anong, struct nfsd4_fs_locations *fsloc)
 {
        show_expflags(m, flag, NFSEXP_ALLFLAGS);
        if (flag & NFSEXP_FSID)
                seq_printf(m, ",fsid=%d", fsid);
-       if (anonu != (uid_t)-2 && anonu != (0x10000-2))
-               seq_printf(m, ",anonuid=%u", anonu);
-       if (anong != (gid_t)-2 && anong != (0x10000-2))
-               seq_printf(m, ",anongid=%u", anong);
+       if (!uid_eq(anonu, make_kuid(&init_user_ns, (uid_t)-2)) &&
+           !uid_eq(anonu, make_kuid(&init_user_ns, 0x10000-2)))
+               seq_printf(m, ",anonuid=%u", from_kuid(&init_user_ns, anonu));
+       if (!gid_eq(anong, make_kgid(&init_user_ns, (gid_t)-2)) &&
+           !gid_eq(anong, make_kgid(&init_user_ns, 0x10000-2)))
+               seq_printf(m, ",anongid=%u", from_kgid(&init_user_ns, anong));
        if (fsloc && fsloc->locations_count > 0) {
                char *loctype = (fsloc->migrated) ? "refer" : "replicas";
                int i;
index 24c139288db4a1b97022780fedcd1d8313903424..7898c997dfea400438f4f9700293f939f38b72ea 100644 (file)
@@ -49,8 +49,8 @@ struct svc_export {
        struct auth_domain *    ex_client;
        int                     ex_flags;
        struct path             ex_path;
-       uid_t                   ex_anon_uid;
-       gid_t                   ex_anon_gid;
+       kuid_t                  ex_anon_uid;
+       kgid_t                  ex_anon_gid;
        int                     ex_fsid;
        unsigned char *         ex_uuid; /* 16 byte fsid */
        struct nfsd4_fs_locations ex_fslocs;