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)
Fri, Mar 22, 9:14 PM
Unknown Object (File)
Fri, Mar 22, 9:13 PM
Unknown Object (File)
Fri, Mar 22, 9:13 PM
Unknown Object (File)
Fri, Mar 22, 9:13 PM
Unknown Object (File)
Sat, Mar 9, 7:34 AM
Unknown Object (File)
Wed, Mar 6, 9:12 PM
Unknown Object (File)
Feb 8 2024, 5:40 AM
Unknown Object (File)
Feb 3 2024, 2:33 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 33989

Event Timeline

kib added inline comments.
usr.sbin/mountd/mountd.c
1831

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

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

3525

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