From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 58B5F3861854; Tue, 11 Aug 2020 10:24:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58B5F3861854 From: "mztyvop at 0pointer dot net" To: glibc-bugs@sourceware.org Subject: [Bug libc/26371] New: [RFE] please add clone3() wrapper (in particular the CLONE_INTO_CGROUP feature of it) Date: Tue, 11 Aug 2020 10:24:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mztyvop at 0pointer dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 10:24:23 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26371 Bug ID: 26371 Summary: [RFE] please add clone3() wrapper (in particular the CLONE_INTO_CGROUP feature of it) Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: mztyvop at 0pointer dot net CC: drepper.fsp at gmail dot com Target Milestone: --- In systemd we'd really like to make use of the new CLONE_INTO_CGROUP kernel feature available for clone3(). It would allows us removing some really ugly code in systemd: right now whenever PID 1 forks off a service process we manually migrate the process into the destination cgroup and we do this twi= ce (once from the parent/PID 1 and once from the child, since we need to be su= re the migration is complete before we continue in either).=20 Unfortunately I don't see how we can properly make use of this in systemd, without glibc providing some form of support for clone3() for us. The problem is that if we issue clone3() with our own wrapper, glibc won't = know about the call. Then, when in the child we issue setgroups(), setuid() and = so on, the setxuid propagation stuff in glibc tries to propagate these credent= ial changes to other threads =E2=80=94 threads that don't actually exist in the= child... Since issuing setuid() in some form is very typical during service invocati= on this means this pretty systematically deadlocks if we use clone3(). And that sucks. I am not aware of any work-around for this: we cannot tell glibc that a clone/fork has happened, we cannot tell glibc that all threads that existed= in the parent suddenly vanished.=20 Hence, it would be great if glibc would gain a clone3() wrapper. Or alternatively some way how we can turn off setxid propagation in the child?= Or some way to tell glibc that a clone/fork/clone3 happened and it should forg= et about all its thread info? Here's a systemd PR that implements things in systemd with a manual wrapper= for clone3(), and that then triggers the setxid deadlock as mentioned in the ch= ild: https://github.com/systemd/systemd/pull/16706 Ideas, suggestions how to deal with this with current glibc would be very welcome. I'd be quite sad if we'd have to wait for glibc() to wrap clone3() natively to make use of this new concept. --=20 You are receiving this mail because: You are on the CC list for the bug.=