use initgroups_dyn-less nss impls in a thread-safer way
Alexandre Oliva
aoliva@redhat.com
Fri Jan 20 04:24:00 GMT 2012
AFAICT, nscd may call getgrouplist() from multiple threads
simultaneously.
This is fine for all (?) nss implementations provided by glibc itself,
for they supply a thread-safe implementation of the inigroups_dyn entry
point.
However, for other nss impementations that don't, as well as for older
versions of glibc that didn't have _nss_files_initgroups_dyn, this means
nscd threads may interfere with one another as they iterate over the
group list with the not-really-reentrant getgrent_r, so that they get
non-overlapping subsets of the group entries.
I realize this might not be the best place for this fix; arguably, nscd
should avoid concurrency issues when using such not-really-reentrant
interfaces like any other program, but since its whole point is to
improve performance and holding an unnecessary lock around every
getgrouplist call would hurt it, I propose a change that will have a
minimal impact that may be easily avoided by introducing an
initgroups_dyn entry point, and that will increase the odds of
correctness for general uses that don't take care of locking
getgrouplist() themselves (as long as they don't getgrent*
concurrently).
Is this ok?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compat-initgroups-mutex-bz706571.patch
Type: text/x-diff
Size: 1322 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120120/be19dbc1/attachment.bin>
-------------- next part --------------
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer
More information about the Libc-alpha
mailing list