userns changes for 9p, afs, ceph, cifs, coda, gfs2, ncpfs, nfs, nfsd, and ocfs2
Subsystems (11)
Re: [PATCH review 23/85] ocfs2: Convert uid and gids between in core and on disk inodes
In reply to Joel BeckerQuoted 3 lines · Joel Becker
This has the same problem with two machines in different userspace namespaces. Should this be punted to the sysadmin or helped out in the filesystem? Do you define this case as unsupported?
First I define two machines in the same user namespace as two machines with synchronized password files.
As today connecting two machines without synchronizing the password entries is a problem, won't work, and is punted to the sysadmin to make keep from doing something silly.
At the same time I don't want to make it easy to get confused, or cause breakage.
With these patches ocfs2 only still only works in the initial user namespace. I don't set .fs_flags = FS_USERNS_MOUNT in struct filesystem. Which means that while users in other user namespaces can store files on ocfs2, they can't mount ocfs2.
Eric
Re: [PATCH review 23/85] ocfs2: Convert uid and gids between in core and on disk inodes
In reply to Joel BeckerQuoted 3 lines · Joel Becker
This has the same problem with two machines in different userspace namespaces. Should this be punted to the sysadmin or helped out in the filesystem? Do you define this case as unsupported?
First I define two machines in the same user namespace as two machines with synchronized password files.
As today connecting two machines without synchronizing the password entries is a problem, won't work, and is punted to the sysadmin to make keep from doing something silly.
At the same time I don't want to make it easy to get confused, or cause breakage.
With these patches ocfs2 only still only works in the initial user namespace. I don't set .fs_flags = FS_USERNS_MOUNT in struct filesystem. Which means that while users in other user namespaces can store files on ocfs2, they can't mount ocfs2.
Eric
Re: [PATCH review 52/85] sunrpc: Properly encode kuids and kgids in auth.unix.gid rpc pipe upcalls.
In reply to Eric W. BiedermanQuoted 19 lines · Eric W. Biederman
Quoted 9 lines · J. Bruce Fields
Quoted 3 lines · Eric W. Biederman
Now looking at the nfs server, seems to be hard coded to only start in the initial network namespace despite almost having support for starting in more.
Right, Stanislav's got 4 more patches that should finish the job; see
http://mid.gmane.org/<20130201125210.3257.46454.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]>
and followups. That should make it for 3.9, I just need to review them....Ok that is interesting.
There is an interesting corner case here where an unprivileged user can create a user namespace and then can create a network namespace. Depending on how we interpret things when Stanislaves patches reach there we might have to add:
Quoted 4 lines
if (
net->user_ns!=&init_user_ns)
-EINVALSomewhere appropriate.
I'm assuming that's something that's needed only in kernels that have *both* Stanislav's patches and yours.
I've committed his patches to
git://linux-nfs.org/~bfields/linux.git for-3.9
which should also get pulled into next. Let me know if there's another patch I should take.
Quoted 4 lines
I am a touch concerned about
/proc/fs/nfsd/exportsafter my patches and Stanislavs patches both come in. As I think that will allow for cases wherenet->user_ns!=&init_userns. But we can cross that bridge when we come to it.
OK, let me know of anything I can do to make your life easier....
--b.
Re: [PATCH review 52/85] sunrpc: Properly encode kuids and kgids in auth.unix.gid rpc pipe upcalls.
Quoted 8 lines · J. Bruce Fields
On Wed, Feb 13, 2013 at 03:22:32PM -0800, Eric W. Biederman wrote:
I've committed his patches to
git://linux-nfs.org/~bfields/linux.git for-3.9which should also get pulled into next. Let me know if there's another patch I should take.
I don't currently see any problems.
My changes are now in:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-next
So we will get whatever linux-next testing there is.
Quoted 6 lines
Quoted 4 lines
I am a touch concerned about
/proc/fs/nfsd/exportsafter my patches and Stanislavs patches both come in. As I think that will allow for cases wherenet->user_ns!=&init_userns. But we can cross that bridge when we come to it.OK, let me know of anything I can do to make your life easier....
/proc/fs/nfsd/exports is read-only so it turns out not be be a problem.
That we can not mount nfs or the nfsd control filesystem outside of init_userns prevents any other problems. Details are in my conversation with Stanislav.
Eric
p.s. It would be nice if /proc/fs/nfsd/exports became a symlink to /proc/net/nfsd/exports so the code didn't have to use current to figure out how to do the right thing.
p.p.s Full user namespace support probably isn't much more than using net->user_ns and adding the FS_USERNS_MOUNT flag.
Re: [PATCH review 49/85] sunrpc: Update svcgss xdr handle to rpsec_contect cache
In reply to Eric W. BiedermanQuoted 39 lines · Eric W. Biederman
From: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/[email protected]>
For each received uid call
make_kuidand validate the result. For each received gid callmake_kgidand validate the result.Cc "J. Bruce Fields" <[email protected]>Cc Trond Myklebust <[email protected]>--- net/sunrpc/auth_gss/svcauth_gss.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)net/sunrpc/auth_gss/svcauth_gss.c +4
-1@@ -418,6 +418,7 @@ static int rsc_parse(struct cache_detail *cd, {/* contexthandle expiry [ uid gid N <n gids> mechname ...mechdata... ] */ char *buf = mesg; +int id;int len, rv;struct rsc rsci, *rscp =NULL ;time_t expiry;@@ -444,7 +445,7 @@ static int rsc_parse(struct cache_detail *cd, goto out;/* uid, or NEGATIVE */ - rv =get_int (&mesg, &rsci.cred.cr_uid); + rv =get_int (&mesg, &id);if (rv == -EINVAL ) goto out;if (rv == -ENOENT )@@ -452,8 +453,16 @@ static int rsc_parse(struct cache_detail *cd,else {int N , i; +/* uid */ + rsci.cred.cr_uid =make_kuid (&init_user_ns, id);
net/sunrpc/auth_gss/svcauth_gss.c static int rsc_parse(struct cache_detail *cd, · line 466
Quoted 10 lines
net/sunrpc/auth_gss/svcauth_gss.c +7
-1+if (!uid_valid (rsci.cred.cr_uid)) + goto out; +/* gid */ -if (get_int (&mesg, &rsci.cred.cr_gid)) +if (get_int (&mesg, &id)) + goto out; + rsci.cred.cr_gid =make_kgid (&init_user_ns, id); +if (!gid_valid (rsci.cred.cr_gid)) goto out;
krb5 mounts started failing for me as of this patch (upstream as 683428fae8c73d7d7da0fa2e0b6beb4d8df4e808), and I believe the problem is these uid/gid_valid checks: if I recall correctly, gssd uses -1 uid/gid values to indicate "authentication succeeded, but treat this user as anonymous". We delay mapping -1 id's to the (configurable-per-export) anonymous id's till fs/nfsd/auth.c:nfsd_setuser():
if (uid_eq(new->fsuid, INVALID_UID)) new->fsuid = exp->ex_anon_uid; if (gid_eq(new->fsgid, INVALID_GID)) new->fsgid = exp->ex_anon_gid;
(We wouldn't be able to do that earlier because we don't know the export yet.)
Confirmed that the following fixes the regression.
Eric, any objection to removing those checks?
--b.
net/sunrpc/auth_gss/svcauth_gss.c +0 -4
@@ -449,15 +449,11 @@ static int rsc_parse(struct cache_detail *cd,/* uid */ rsci.cred.cr_uid =make_kuid (&init_user_ns, id); -if (!uid_valid (rsci.cred.cr_uid)) - goto out;/* gid */ if (get_int (&mesg, &id)) goto out; rsci.cred.cr_gid =make_kgid (&init_user_ns, id); -if (!gid_valid (rsci.cred.cr_gid)) - goto out;/* number of additional gid's */ if (get_int (&mesg, &N ))
Re: [PATCH review 49/85] sunrpc: Update svcgss xdr handle to rpsec_contect cache
Quoted 2 lines · J. Bruce Fields
krb5 mounts started failing for me as of this patch (upstream as
683428fae8c73d7d7da0fa2e0b6beb4d8df4e808),
Ouch!
Quoted 11 lines
and I believe the problem is
these uid/gid_valid checks: if I recall correctly, gssd uses -1 uid/gid values to indicate "authentication succeeded, but treat this user as anonymous". We delay mapping -1 id's to the (configurable-per-export) anonymous id's till fs/nfsd/auth.c:nfsd_setuser():if (uid_eq(new->fsuid, INVALID_UID)) new->fsuid = exp->ex_anon_uid; if (gid_eq(new->fsgid, INVALID_GID)) new->fsgid = exp->ex_anon_gid;
Quoted 6 lines
(We wouldn't be able to do that earlier because we don't know the export yet.)
Confirmed that the following fixes the regression.
Eric, any objection to removing those checks?
Not strongly. As long as we have the uid ang gid valid checks in there somewhere before we start using these uids and gids much. This does seems to be the case of using out of range uids and gids to mean out of range uids and gids.
In the description of my original patch before I split it up, I noted that one of the small dangers might be that I had added some possibly unneceessary uid and gid valid checks. So it seems I had even considered this slight possibility once and noted that there was a slight chance we might have to remove a few of these.
It would be nice to have a comment to say that we expect this to happen so people don't start wondering why there are missing checks on this path.
There is also a gid_valid check in the secondary uids. It looks like we should keep that as we don't have any checks for invalid gids in nfsd_setuser. Is that possibly an oversight in nfsd_setuser?
Also looking towards a future in which all of these things don't reside in the initial user namespace. Is mapping any out of range uid to INVALID_UID and then into ex_anon_uid the always the right thing to do?
Or is -1 a very special case in this instance. In which case we probably want checks that look like:
if (-1 == id) {
rsci.cred.cr_uid = INVALID_UID;
} else {
rsci.cred.cr_uid = make_kuid(&init_user_ns, id);
if (!uid_valid(rsci.cred.cr_uid))
goto out;
}Eric
Quoted 20 lines
net/sunrpc/auth_gss/svcauth_gss.c +0
-4@@ -449,15 +449,11 @@ static int rsc_parse(struct cache_detail *cd,/* uid */ rsci.cred.cr_uid =make_kuid (&init_user_ns, id); -if (!uid_valid (rsci.cred.cr_uid)) - goto out;/* gid */ if (get_int (&mesg, &id)) goto out; rsci.cred.cr_gid =make_kgid (&init_user_ns, id); -if (!gid_valid (rsci.cred.cr_gid)) - goto out;/* number of additional gid's */ if (get_int (&mesg, &N ))
Re: [PATCH review 49/85] sunrpc: Update svcgss xdr handle to rpsec_contect cache
In reply to a message not in the archiveQuoted 2 lines · J. Bruce Fields
krb5 mounts started failing for me as of this patch (upstream as
683428fae8c73d7d7da0fa2e0b6beb4d8df4e808),
Ouch!
Quoted 11 lines
and I believe the problem is
these uid/gid_valid checks: if I recall correctly, gssd uses -1 uid/gid values to indicate "authentication succeeded, but treat this user as anonymous". We delay mapping -1 id's to the (configurable-per-export) anonymous id's till fs/nfsd/auth.c:nfsd_setuser():if (uid_eq(new->fsuid, INVALID_UID)) new->fsuid = exp->ex_anon_uid; if (gid_eq(new->fsgid, INVALID_GID)) new->fsgid = exp->ex_anon_gid;
Quoted 6 lines
(We wouldn't be able to do that earlier because we don't know the export yet.)
Confirmed that the following fixes the regression.
Eric, any objection to removing those checks?
Not strongly. As long as we have the uid ang gid valid checks in there somewhere before we start using these uids and gids much. This does seems to be the case of using out of range uids and gids to mean out of range uids and gids.
In the description of my original patch before I split it up, I noted that one of the small dangers might be that I had added some possibly unneceessary uid and gid valid checks. So it seems I had even considered this slight possibility once and noted that there was a slight chance we might have to remove a few of these.
It would be nice to have a comment to say that we expect this to happen so people don't start wondering why there are missing checks on this path.
There is also a gid_valid check in the secondary uids. It looks like we should keep that as we don't have any checks for invalid gids in nfsd_setuser. Is that possibly an oversight in nfsd_setuser?
Also looking towards a future in which all of these things don't reside in the initial user namespace. Is mapping any out of range uid to INVALID_UID and then into ex_anon_uid the always the right thing to do?
Or is -1 a very special case in this instance. In which case we probably want checks that look like:
if (-1 == id) {
rsci.cred.cr_uid = INVALID_UID;
} else {
rsci.cred.cr_uid = make_kuid(&init_user_ns, id);
if (!uid_valid(rsci.cred.cr_uid))
goto out;
}Eric
Quoted 20 lines
net/sunrpc/auth_gss/svcauth_gss.c +0
-4@@ -449,15 +449,11 @@ static int rsc_parse(struct cache_detail *cd,/* uid */ rsci.cred.cr_uid =make_kuid (&init_user_ns, id); -if (!uid_valid (rsci.cred.cr_uid)) - goto out;/* gid */ if (get_int (&mesg, &id)) goto out; rsci.cred.cr_gid =make_kgid (&init_user_ns, id); -if (!gid_valid (rsci.cred.cr_gid)) - goto out;/* number of additional gid's */ if (get_int (&mesg, &N ))
Re: [PATCH review 49/85] sunrpc: Update svcgss xdr handle to rpsec_contect cache
In reply to Eric W. BiedermanQuoted 31 lines · Eric W. Biederman
Quoted 2 lines · J. Bruce Fields
krb5 mounts started failing for me as of this patch (upstream as
683428fae8c73d7d7da0fa2e0b6beb4d8df4e808),Ouch!
Quoted 11 lines
and I believe the problem is
these uid/gid_valid checks: if I recall correctly, gssd uses -1 uid/gid values to indicate "authentication succeeded, but treat this user as anonymous". We delay mapping -1 id's to the (configurable-per-export) anonymous id's till fs/nfsd/auth.c:nfsd_setuser():if (uid_eq(new->fsuid, INVALID_UID)) new->fsuid = exp->ex_anon_uid; if (gid_eq(new->fsgid, INVALID_GID)) new->fsgid = exp->ex_anon_gid;Quoted 6 lines
(We wouldn't be able to do that earlier because we don't know the export yet.)
Confirmed that the following fixes the regression.
Eric, any objection to removing those checks?
Not strongly. As long as we have the uid ang gid valid checks in there somewhere before we start using these uids and gids much. This does seems to be the case of using out of range uids and gids to mean out of range uids and gids.
Quoted 5 lines
In the description of my original patch before I split it up, I noted that one of the small dangers might be that I had added some possibly unneceessary uid and gid valid checks. So it seems I had even considered this slight possibility once and noted that there was a slight chance we might have to remove a few of these.
Ah, I should have seen that and checked that, my bad.
Quoted 3 lines
It would be nice to have a comment to say that we expect this to happen so people don't start wondering why there are missing checks on this path.
OK--something like the appended?
Quoted 3 lines
There is also a
gid_validcheck in the secondary uids. It looks like we should keep that as we don't have any checks for invalid gids innfsd_setuser. Is that possibly an oversight innfsd_setuser?
Honestly I don't think anyone's thought that through....
But it would seem odd to pass down an "anonymous" supplementary gid--why not just leave it off the list instead?
(BTW, dumb question: is it legal for userspace to use a uid -1? And was it illegal before the user namespace patches?)
Quoted 6 lines
Also looking towards a future in which all of these things don't reside in the initial user namespace. Is mapping any out of range uid to
INVALID_UIDand then intoex_anon_uidthe always the right thing to do?Or is -1 a very special case in this instance. In which case we probably want checks that look like:
svcgssd should pass down either -1 or a valid uid, so I don't think we're committed to any particular handling of invalid id's other than -1--whatever's easiest.
--b.
commit d78f5cd062edb400190521e9540b042b4805875b
Author: J. Bruce Fields <[email protected]> Date: Mon Mar 4 08:44:01 2013 -0500
nfsd: fix krb5 handling of anonymous principals
krb5 mounts started failing as of 683428fae8c73d7d7da0fa2e0b6beb4d8df4e808 "sunrpc: Update svcgss xdr handle to rpsec_contect cache".
The problem is that mounts are usually done with some host principal which isn't normally mapped to any user, in which case svcgssd passes down uid -1, which the kernel is then expected to map to the export-specific anonymous uid or gid.
The new uid_valid/gid_valid checks were therefore causing that downcall to fail.
(Note the regression may not have been seen with older userspace that tended to map unknown principals to an anonymous id on their own rather than leaving it to the kernel.)
net/sunrpc/auth_gss/svcauth_gss.c +8 -4
@@ -447,17 +447,21 @@ static int rsc_parse(struct cache_detail *cd,else {int N , i; +/* +* NOTE: we don't check uid_valid() or gid_valid(): instead, +* -1 id's are later mapped to the (export-specific) +* anonymous id by nfsd_setuser. +* +* (But supplementary gid's get no such special +* treatment so are checked for validity here.) +*/ /* uid */ rsci.cred.cr_uid =make_kuid (&init_user_ns, id); -if (!uid_valid (rsci.cred.cr_uid)) - goto out;/* gid */ if (get_int (&mesg, &id)) goto out; rsci.cred.cr_gid =make_kgid (&init_user_ns, id); -if (!gid_valid (rsci.cred.cr_gid)) - goto out;/* number of additional gid's */ if (get_int (&mesg, &N ))
Eric W. Biederman
Reviewed-byRe: [PATCH review 49/85] sunrpc: Update svcgss xdr handle to rpsec_contect cache
Quoted 9 lines · J. Bruce Fields
Quoted 8 lines · Eric W. Biederman
"J. Bruce Fields" <[email protected]> writes:
Not strongly. As long as we have the uid ang gid valid checks in there somewhere before we start using these uids and gids much. This does seems to be the case of using out of range uids and gids to mean out of range uids and gids.
Quoted 7 lines
Quoted 5 lines
In the description of my original patch before I split it up, I noted that one of the small dangers might be that I had added some possibly unneceessary uid and gid valid checks. So it seems I had even considered this slight possibility once and noted that there was a slight chance we might have to remove a few of these.
Ah, I should have seen that and checked that, my bad.
I think that text was lost when I split my nfs patch into all of those patches so I don't expect you ever saw that text.
Quoted 5 lines
Quoted 3 lines
It would be nice to have a comment to say that we expect this to happen so people don't start wondering why there are missing checks on this path.
OK--something like the appended?
It looks good to me.
Quoted 5 lines
Quoted 3 lines
There is also a
gid_validcheck in the secondary uids. It looks like we should keep that as we don't have any checks for invalid gids innfsd_setuser. Is that possibly an oversight innfsd_setuser?Honestly I don't think anyone's thought that through....
I try and take these moments of that's weird to spark the thinking of things through. Just in case there is something important was overlooked.
Quoted 2 lines
But it would seem odd to pass down an "anonymous" supplementary gid--why not just leave it off the list instead?
True.
Quoted 2 lines
(BTW, dumb question: is it legal for userspace to use a uid -1? And was it illegal before the user namespace patches?)
It is now impossible and thus illegal for userspace to use a uid value of -1. Previously to use a uid of -1 you had to jump through hoops as some system calls would allow it (setuid) and some system calls special cased the value of -1 (setresuid). Which mean using a uid value of -1 was while possible but a bad idea because various things would break in strange ways.
Quoted 10 lines
Quoted 6 lines
Also looking towards a future in which all of these things don't reside in the initial user namespace. Is mapping any out of range uid to
INVALID_UIDand then intoex_anon_uidthe always the right thing to do?Or is -1 a very special case in this instance. In which case we probably want checks that look like:
svcgssd should pass down either -1 or a valid uid, so I don't think we're committed to any particular handling of invalid id's other than -1--whatever's easiest.
Sounds good. I won't worry about them in future development then.
Quoted 15 lines
commit
d78f5cd062edb400190521e9540b042b4805875bAuthor: J. Bruce Fields <[email protected]> Date: Mon Mar 4 08:44:01 2013 -0500nfsd: fix krb5 handling of anonymous principals
krb5 mounts started failing as of
683428fae8c73d7d7da0fa2e0b6beb4d8df4e808"sunrpc: Update svcgss xdr handle torpsec_contectcache".The problem is that mounts are usually done with some host principal which isn't normally mapped to any user, in which case svcgssd passes down uid -1, which the kernel is then expected to map to the export-specific anonymous uid or gid.
Quoted 8 lines
The new uid_valid/gid_valid checks were therefore causing that downcall to fail.
(Note the regression may not have been seen with older userspace that tended to map unknown principals to an anonymous id on their own rather than leaving it to the kernel.)
Signed-off-by J. Bruce Fields <[email protected]>
Quoted 30 lines
net/sunrpc/auth_gss/svcauth_gss.c +8
-4@@ -447,17 +447,21 @@ static int rsc_parse(struct cache_detail *cd,else {int N , i; +/* +* NOTE: we don't check uid_valid() or gid_valid(): instead, +* -1 id's are later mapped to the (export-specific) +* anonymous id by nfsd_setuser. +* +* (But supplementary gid's get no such special +* treatment so are checked for validity here.) +*/ /* uid */ rsci.cred.cr_uid =make_kuid (&init_user_ns, id); -if (!uid_valid (rsci.cred.cr_uid)) - goto out;/* gid */ if (get_int (&mesg, &id)) goto out; rsci.cred.cr_gid =make_kgid (&init_user_ns, id); -if (!gid_valid (rsci.cred.cr_gid)) - goto out;/* number of additional gid's */ if (get_int (&mesg, &N ))