From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14754 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Hangup calling setuid() from vfork() child Date: Mon, 30 Sep 2019 13:41:08 -0400 Message-ID: <20190930174108.GR9017@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="182116"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14770-gllmg-musl=m.gmane.org@lists.openwall.com Mon Sep 30 19:41:23 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iEzfn-000lHk-Ei for gllmg-musl@m.gmane.org; Mon, 30 Sep 2019 19:41:23 +0200 Original-Received: (qmail 11861 invoked by uid 550); 30 Sep 2019 17:41:21 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 11843 invoked from network); 30 Sep 2019 17:41:20 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14754 Archived-At: On Mon, Sep 30, 2019 at 08:29:16AM -0700, Joshua Hudson wrote: > If there is more than one thread and vfork() calls setuid(), musl libc hangs up. > > void *thfunction(void*ig) {sleep(1000);returnNULL;} > > int main() > { > pthread_t id; > pthread_create(&id, NULL, thfunction, NULL); > if (vfork() == 0) { > setuid(0); /* hangup */ > _exit(0); > } > } This is expected; the only legal action after vfork is _exit or execve. In practice you could probably get by with syscall(SYS_setuid,0) or similar in the child, but this isn't supported usage and the specification for vfork has always been clear that you can't do arbitrary stuff in the child. If you need to, you should be using fork. Rich