[Bug nss/27731] getgrouplist(3) is not thread-safe.

o.seibert at syseleven dot de sourceware-bugzilla@sourceware.org
Wed Jul 24 15:20:41 GMT 2024


https://sourceware.org/bugzilla/show_bug.cgi?id=27731

--- Comment #5 from Olaf Seibert (Syseleven) <o.seibert at syseleven dot de> ---
Thanks for your elucidation! I totally agree with "that getgrouplist(), which
has no synchronizaiton requirements with other threads, which is a single call,
can if implemented correctly, return consistent results?"

And indeed it looks like "something" implements getgrouplist() in terms of
setent(), getent(), and endent() (or similar) calls. I just haven't found where
exactly. Unfortunately the stack trace from my initial report does not have all
names resolved. But it does appear that this is somewhere in glibc:

(gdb) bt
#0  0x00007f694e7eb3c0 in _nss_extrausers_setgrent () from
/usr/lib/libnss_extrausers.so.2
#1  0x00007f695c72750a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007f695c72793e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007f695c727ab1 in getgrouplist () from /lib/x86_64-linux-gnu/libc.so.6
[ remaining frames are from the third-party program - omitted ]

Looking through the code I find that getgrouplist() calls internal_getgrouplist
() but there it becomes a bit of a maze. I suspect that the call

__nss_lookup_function (nip, initgroups_dyn")

fails since nss-extrausers doesn't have a function called
_nss_extrausers_initgroups_dyn(). Maybe if that function existed it could work
properly (but I didn't dig that deep). Googling for "initgroups_dyn" finds me
https://libc-alpha.sourceware.narkive.com/TJdFEnEP/use-initgroups-dyn-less-nss-impls-in-a-thread-safer-way
which suggests that adding such a function to nss-extrausers would be the
proper solution.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list