Page MenuHomeFreeBSD

fix mountd.c so that it does not allocate 4K for credential groups unless a large groups list is needed
ClosedPublic

Authored by rmacklem on Sep 22 2020, 2:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 10:53 PM
Unknown Object (File)
Tue, Nov 5, 8:48 PM
Unknown Object (File)
Thu, Oct 31, 9:55 AM
Unknown Object (File)
Oct 21 2024, 4:20 PM
Unknown Object (File)
Oct 15 2024, 1:07 AM
Unknown Object (File)
Oct 4 2024, 11:27 AM
Unknown Object (File)
Sep 21 2024, 11:29 PM
Unknown Object (File)
Sep 5 2024, 3:31 PM
Subscribers

Details

Summary

r362163 upgraded mountd so that it could handle MAX_NGROUPS
groups for the anonymous user credentials (the ones provided by
-maproot and -mapall exports options).
The problem is that this resulted in every export structure growing by
about 4Kbytes, because the cr_groups field went from 16->MAX_NGROUPS.

This patch fixes this by only including a small 32 element cr_groups in the
structure and then malloc()'ng cr_groups when a larger one is needed.
The value of SMALLNGROUPS is arbitrarily set to 32, assuming most users
used by -maproot or -mapall will be in <= 32 groups.

Test Plan

Tested by doing an export entry with -maproot=ricktst,
when ricktst was in > SMALLNGROUPS groups.
For the test, syslog() calls were added to ensure the
malloc()s and free()s of the large cr_groups list
happened at the correct times.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
usr.sbin/mountd/mountd.c
1831 ↗(On Diff #77339)

I find a test like anon.cr_groups != anon.cr_smallgrps more clean, instead of relying on the size comparision.

This revision is now accepted and ready to land.Sep 22 2020, 5:27 PM
freqlabs added inline comments.
usr.sbin/mountd/mountd.c
3483 ↗(On Diff #77339)

I take it this will not be in the committed version?

3528 ↗(On Diff #77339)

How about using memcpy here, too?

Updated with changes as suggested by kib@ and freqlabs@.

This revision now requires review to proceed.Oct 4 2020, 10:42 PM
This revision is now accepted and ready to land.Oct 5 2020, 2:00 AM