nfsd: Fix sort_pacl in fs/nfsd/nf4acl.c to actually sort groups
Subsystems (2)
PATCH 1/1 nfsd: Fix sort_pacl in fs/nfsd/nf4acl.c to actually sort groups
We have been doing some extensive testing of Linux support for ACLs on NFDS v4. We have noticed that the server rejects ACLs where the groups are out of order, for example, the following ACL is rejected:
A::OWNER@:rwaxtTcCy
A::user101@domain:rwaxtcy
A::GROUP@:rwaxtcy
A:g:group102@domain:rwaxtcy
A:g:group101@domain:rwaxtcy
A::EVERYONE@:rwaxtcy
Examining the server code, I found that after converting an NFS v4 ACL to POSIX, sort_pacl is called to sort the user ACEs and group ACEs. Unfortunately, a minor bug causes the group sort to be skipped.
--- fs/nfsd/nfs4acl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfs4acl.c +1 -1
@@ -389,7 +389,7 @@ sort_pacl(struct posix_acl *pacl)sort_pacl_range (pacl,1 , i-1 );BUG_ON (pacl->a_entries[i].e_tag !=ACL_GROUP_OBJ ); - j = i++; + j = ++i;while (pacl->a_entries[j].e_tag ==ACL_GROUP ) j++;sort_pacl_range (pacl, i, j-1 );
Signature · 1 line
1.5.2.2
J. Bruce Fields
AppliedQuoted 11 lines · Frank Filz
We have been doing some extensive testing of Linux support for ACLs on NFDS v4. We have noticed that the server rejects ACLs where the groups are out of order, for example, the following ACL is rejected:
A::OWNER@:rwaxtTcCy
A::user101@domain:rwaxtcy
A::GROUP@:rwaxtcy
A:g:group102@domain:rwaxtcy
A:g:group101@domain:rwaxtcy
A::EVERYONE@:rwaxtcy
Quoted 3 lines
Examining the server code, I found that after converting an NFS v4 ACL to POSIX,
sort_paclis called to sort the user ACEs and group ACEs. Unfortunately, a minor bug causes the group sort to be skipped.
Good grief, I'm embarassed--OK, thanks for catching that! Do you have any regression tests that'd be easy for someone else to run?
Applied.
--b.
Quoted 28 lines
Signed-off-by Frank Filz <[email protected]>--- fs/nfsd/nfs4acl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/nfsd/nfs4acl.c +1
-1@@ -389,7 +389,7 @@ sort_pacl(struct posix_acl *pacl)sort_pacl_range (pacl,1 , i-1 );BUG_ON (pacl->a_entries[i].e_tag !=ACL_GROUP_OBJ ); - j = i++; + j = ++i;while (pacl->a_entries[j].e_tag ==ACL_GROUP ) j++;sort_pacl_range (pacl, i, j-1 );Signature · 8 lines
1.5.2.2 _______________________________________________ NFSv4 mailing list [email protected] http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
Quoted 12 lines · J. Bruce Fields
Quoted 11 lines · Frank Filz
We have been doing some extensive testing of Linux support for ACLs on NFDS v4. We have noticed that the server rejects ACLs where the groups are out of order, for example, the following ACL is rejected:
A::OWNER@:rwaxtTcCy
A::user101@domain:rwaxtcy
A::GROUP@:rwaxtcy
A:g:group102@domain:rwaxtcy
A:g:group101@domain:rwaxtcy
A::EVERYONE@:rwaxtcy
Quoted 6 lines
Quoted 3 lines
Examining the server code, I found that after converting an NFS v4 ACL to POSIX,
sort_paclis called to sort the user ACEs and group ACEs. Unfortunately, a minor bug causes the group sort to be skipped.Good grief, I'm embarassed--OK, thanks for catching that! Do you have any regression tests that'd be easy for someone else to run?
Using the above ACL (modified with appropriate groups and the appropriate domain) with nfs4_setfacl will result in an EINVAL/Invalid argument.
I'm working on a script to test ACL conversion, I will post it when it is in a better state for public consumption. It does an exhaustive test (which in full mode takes a day or two to complete), but I could add a regression test that just hit various spot conditions (it will also have to get smart about the ACL re-ordering in order to have an automated regression test for this error).
We actually hit the bug by using nfs4_setfacl -a, discovering that the command only succeeded if the index was specified to put the new group ACE in the correct sorted position.
Thanks
Frank