Skip to content

Commit 1995266

Browse files
bwh-cttorvalds
authored andcommitted
nfsd: auth: Fix gid sorting when rootsquash enabled
Commit bdcf0a4 ("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: bdcf0a4 ("kernel: make groups_sort calling a responsibility ...") Signed-off-by: Ben Hutchings <[email protected]> Acked-by: J. Bruce Fields <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a0ec1de commit 1995266

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/nfsd/auth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
6060
gi->gid[i] = exp->ex_anon_gid;
6161
else
6262
gi->gid[i] = rqgi->gid[i];
63-
64-
/* Each thread allocates its own gi, no race */
65-
groups_sort(gi);
6663
}
64+
65+
/* Each thread allocates its own gi, no race */
66+
groups_sort(gi);
6767
} else {
6868
gi = get_group_info(rqgi);
6969
}

0 commit comments

Comments
 (0)