Bug 10563 - supplementary groups are not shared between (p)threads
Summary: supplementary groups are not shared between (p)threads
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.9
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-25 22:49 UTC by Kamil Iskra
Modified: 2014-07-01 08:34 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Last reconfirmed:
fweimer: security+


Attachments
self-contained testcase (618 bytes, text/plain)
2009-08-25 22:51 UTC, Kamil Iskra
Details
use INLINE_SETXID_SYSCALL for setgroups() (402 bytes, patch)
2011-01-11 01:51 UTC, Mark Heily
Details | Diff
Additional testcase (1.16 KB, text/x-csrc)
2011-01-11 02:11 UTC, Mark Heily
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Iskra 2009-08-25 22:49:46 UTC
I noticed that supplementary groups (getgroups(2)/setgroups(2)) are not shared
between the threads in a multithreaded program.  I would expect that since
[e]uid and [e]gid are, so should the supplementary groups?  I checked the source
and I can see that set*id() calls use the setxid API to synchronize the ids
between the threads, but setgroups() does not do that; I guess that's the
problem.  I didn't try to compile the latest version, but the source is the same
in that respect...

This is with kernel 2.6.30, gcc 4.3.2, binutils 2.18, but I don't think this
matters all that much, as I first saw it on a completely different platform
(PPC64 SLES 10).

I'll attach a self-contained testcode.  It needs to be run as root.  I'm getting
the following output:

"Initial groups:
0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27

Launched a new thread

Changing groups in the main thread...

Main thread groups:
12345

Launched thread groups:
0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27"

Instead, I would expect the last line to be "12345".
Comment 1 Kamil Iskra 2009-08-25 22:51:44 UTC
Created attachment 4151 [details]
self-contained testcase
Comment 2 Mark Heily 2011-01-11 01:51:47 UTC
Created attachment 5187 [details]
use INLINE_SETXID_SYSCALL for setgroups()

The attached patch converts setgroups() to use INLINE_SETXID_SYSCALL which should hopefully fix the problem. I havn't tested it, and don't know if there is anything else that needs to be done.
Comment 3 Mark Heily 2011-01-11 02:11:32 UTC
Created attachment 5188 [details]
Additional testcase
Comment 4 Ulrich Drepper 2011-01-14 13:42:57 UTC
I checked in some changes.
Comment 5 Florian Weimer 2014-07-01 06:59:07 UTC
This should probably treated as a security issue because it can interact with relinquishing privileges.
Comment 6 Florian Weimer 2014-07-01 08:34:33 UTC
Fixed in commit 70181fddf1467996bea393d13294ffe76b8a0853, which went into glibc 2.13.