diff options
| author | Trond Myklebust <trondmy@gmail.com> | 2019-04-09 19:13:42 +0300 | 
|---|---|---|
| committer | J. Bruce Fields <bfields@redhat.com> | 2019-04-24 16:46:35 +0300 | 
| commit | e45d1a1835b889676374fb74ff4d0e6b06ad173f (patch) | |
| tree | ccb99869e92ef128774ab5a9f2405d3e869a4a80 /fs/nfsd/export.c | |
| parent | e6667c73a27d80078f8d7fca516d6b14bc4e18a7 (diff) | |
| download | linux-e45d1a1835b889676374fb74ff4d0e6b06ad173f.tar.xz | |
nfsd: knfsd must use the container user namespace
Convert knfsd to use the user namespace of the container that started
the server processes.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/export.c')
| -rw-r--r-- | fs/nfsd/export.c | 18 | 
1 files changed, 10 insertions, 8 deletions
| diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 802993d8912f..baa01956a5b3 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -570,13 +570,13 @@ 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= make_kuid(&init_user_ns, an_int); +		exp.ex_anon_uid= make_kuid(current_user_ns(), an_int);  		/* anon gid */  		err = get_int(&mesg, &an_int);  		if (err)  			goto out3; -		exp.ex_anon_gid= make_kgid(&init_user_ns, an_int); +		exp.ex_anon_gid= make_kgid(current_user_ns(), an_int);  		/* fsid */  		err = get_int(&mesg, &an_int); @@ -1170,15 +1170,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,  		kuid_t anonu, kgid_t anong, struct nfsd4_fs_locations *fsloc)  { +	struct user_namespace *userns = m->file->f_cred->user_ns; +  	show_expflags(m, flag, NFSEXP_ALLFLAGS);  	if (flag & NFSEXP_FSID)  		seq_printf(m, ",fsid=%d", fsid); -	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 (!uid_eq(anonu, make_kuid(userns, (uid_t)-2)) && +	    !uid_eq(anonu, make_kuid(userns, 0x10000-2))) +		seq_printf(m, ",anonuid=%u", from_kuid_munged(userns, anonu)); +	if (!gid_eq(anong, make_kgid(userns, (gid_t)-2)) && +	    !gid_eq(anong, make_kgid(userns, 0x10000-2))) +		seq_printf(m, ",anongid=%u", from_kgid_munged(userns, anong));  	if (fsloc && fsloc->locations_count > 0) {  		char *loctype = (fsloc->migrated) ? "refer" : "replicas";  		int i; | 
