Ben Hutchings 54e67ba7d2 nfsd: auth: Fix gid sorting when rootsquash enabled
commit 1995266727fa8143897e89b55f5d3c79aa828420 upstream.

Commit bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility
group_info allocators") appears to break nfsd rootsquash in a pretty
major way.

It adds a call to groups_sort() inside the loop that copies/squashes
gids, which means the valid gids are sorted along with the following
garbage.  The net result is that the highest numbered valid gids are
replaced with any lower-valued garbage gids, possibly including 0.

We should sort only once, after filling in all the gids.

Fixes: bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility ...")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Acked-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Wolfgang Walter <linux@stwm.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-31 14:03:50 +01:00
..
2017-12-14 09:53:15 +01:00
2018-01-31 14:03:42 +01:00
2017-12-20 10:10:17 +01:00
2017-08-24 13:23:03 -07:00
2017-12-14 09:53:14 +01:00
2017-11-30 08:40:45 +00:00
2017-09-04 19:05:15 -04:00
2017-11-30 08:40:53 +00:00
2017-10-18 14:51:50 -04:00
2018-01-05 15:48:57 +01:00