From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Weimer Subject: Re: RFC: on adding new CLONE_* flags [WAS Re: [PATCH 0/4] clone: add CLONE_PIDFD] Date: Tue, 30 Apr 2019 09:01:52 +0200 Message-ID: <87muk8asdb.fsf@oldenburg2.str.redhat.com> References: <20190414201436.19502-1-christian@brauner.io> <20190415195911.z7b7miwsj67ha54y@yavin> <20190420071406.GA22257@ip-172-31-15-78> <87zho8bl8x.fsf@oldenburg2.str.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: (Linus Torvalds's message of "Mon, 29 Apr 2019 14:31:30 -0700") Sender: linux-kernel-owner@vger.kernel.org To: Linus Torvalds Cc: Jann Horn , Kevin Easton , Andy Lutomirski , Christian Brauner , Aleksa Sarai , "Enrico Weigelt, metux IT consult" , Al Viro , David Howells , Linux API , LKML , "Serge E. Hallyn" , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Thomas Gleixner , Michael Kerrisk , Andrew Morton , Oleg Nesterov , Joel Fernandes , Daniel Colascione List-Id: linux-api@vger.kernel.org * Linus Torvalds: > On Mon, Apr 29, 2019 at 1:38 PM Florian Weimer wrote: >> >> In Linux-as-the-ABI (as opposed to Linux-as-the-implementation), vfork >> is sometimes implemented as fork, so applications cannot rely on the >> vfork behavior regarding the stopped parent and the shared address >> space. > > What broken library does that? > > Sure, we didn't have a proper vfork() long long long ago. But that > predates both git and BK, so it's some time in the 90's. We've had a > proper vfork() *forever*. It's not so much about libraries, it's alternative implementations of the system call interface: valgrind, qemu-user and WSL. For valgrind and qemu-user, it's about cloning the internal data structures, so that the subprocess does not clobber what's in the parent process (which may have multiple threads and may not be fully blocked due to vfork). For WSL, who knows what's going on there. >> In fact, it would be nice to have a flag we can check in the posix_spawn >> implementation, so that we can support vfork-as-fork without any run >> time cost to native Linux. > > No. Just make a bug-report to whatever broken library you use. What's > the point of having a library that can't even get vfork() right? Why > would you want to have a flag to say "vfork is broken"? It's apparently quite difficult to fix valgrind and qemu-user. WSL is apparently not given the resources it needs, yet a surprising number of people see it as a viable replacement and report what are essentially vfork-related bugs. If I had the flag, I could at least fix posix_spawn in glibc to consult it before assuming that vfork shares address space. (The sharing allows straightforward reporting of the vfork error code, without resorting to pipes or creating a MAP_SHARED mapping.) For obvious reasons, I do not want to apply the workaround unconditionally. Thanks, Florian From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CA99C43219 for ; Tue, 30 Apr 2019 07:02:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12E4A2075E for ; Tue, 30 Apr 2019 07:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbfD3HCE (ORCPT ); Tue, 30 Apr 2019 03:02:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35492 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbfD3HCE (ORCPT ); Tue, 30 Apr 2019 03:02:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CC433091740; Tue, 30 Apr 2019 07:02:03 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0807D1001E86; Tue, 30 Apr 2019 07:01:53 +0000 (UTC) From: Florian Weimer To: Linus Torvalds Cc: Jann Horn , Kevin Easton , Andy Lutomirski , Christian Brauner , Aleksa Sarai , "Enrico Weigelt\, metux IT consult" , Al Viro , David Howells , Linux API , LKML , "Serge E. Hallyn" , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Thomas Gleixner , Michael Kerrisk , Andrew Morton , Oleg Nesterov , Joel Fernandes , Daniel Colascione Subject: Re: RFC: on adding new CLONE_* flags [WAS Re: [PATCH 0/4] clone: add CLONE_PIDFD] References: <20190414201436.19502-1-christian@brauner.io> <20190415195911.z7b7miwsj67ha54y@yavin> <20190420071406.GA22257@ip-172-31-15-78> <87zho8bl8x.fsf@oldenburg2.str.redhat.com> Date: Tue, 30 Apr 2019 09:01:52 +0200 In-Reply-To: (Linus Torvalds's message of "Mon, 29 Apr 2019 14:31:30 -0700") Message-ID: <87muk8asdb.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Apr 2019 07:02:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Linus Torvalds: > On Mon, Apr 29, 2019 at 1:38 PM Florian Weimer wrote: >> >> In Linux-as-the-ABI (as opposed to Linux-as-the-implementation), vfork >> is sometimes implemented as fork, so applications cannot rely on the >> vfork behavior regarding the stopped parent and the shared address >> space. > > What broken library does that? > > Sure, we didn't have a proper vfork() long long long ago. But that > predates both git and BK, so it's some time in the 90's. We've had a > proper vfork() *forever*. It's not so much about libraries, it's alternative implementations of the system call interface: valgrind, qemu-user and WSL. For valgrind and qemu-user, it's about cloning the internal data structures, so that the subprocess does not clobber what's in the parent process (which may have multiple threads and may not be fully blocked due to vfork). For WSL, who knows what's going on there. >> In fact, it would be nice to have a flag we can check in the posix_spawn >> implementation, so that we can support vfork-as-fork without any run >> time cost to native Linux. > > No. Just make a bug-report to whatever broken library you use. What's > the point of having a library that can't even get vfork() right? Why > would you want to have a flag to say "vfork is broken"? It's apparently quite difficult to fix valgrind and qemu-user. WSL is apparently not given the resources it needs, yet a surprising number of people see it as a viable replacement and report what are essentially vfork-related bugs. If I had the flag, I could at least fix posix_spawn in glibc to consult it before assuming that vfork shares address space. (The sharing allows straightforward reporting of the vfork error code, without resorting to pipes or creating a MAP_SHARED mapping.) For obvious reasons, I do not want to apply the workaround unconditionally. Thanks, Florian