Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbdIFBMG (ORCPT ); Tue, 5 Sep 2017 21:12:06 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:33342 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbdIFBME (ORCPT ); Tue, 5 Sep 2017 21:12:04 -0400 X-Google-Smtp-Source: ADKCNb7qWO0B+5+8LUD9bYzd1VIAfnx5+lF+fmSzwAqY6XByd0kGZtOeERl/ALPdlnFh32t6id4HAw== Subject: Re: execve(NULL, argv, envp) for nommu? To: Alan Cox , Geert Uytterhoeven Cc: Linux Embedded , Oleg Nesterov , dalias@libc.org, "linux-kernel@vger.kernel.org" References: <324c00d9-06a6-1fc5-83fe-5bd36d874501@landley.net> <20170905142436.262ed118@alans-desktop> From: Rob Landley Message-ID: Date: Tue, 5 Sep 2017 20:12:01 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170905142436.262ed118@alans-desktop> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1958 Lines: 46 On 09/05/2017 08:24 AM, Alan Cox wrote: >>> anymore. But I'm already _running_ this program. If I could fork() I >>> could already get a second copy of the sucker and call main() again >>> myself if necessary, but I can't, so... > > You can - ptrace 8) Oh I can call clone() with various flags and try to fake it myself, it just won't do what I want. :) >>> honoring the suid bit if people feel that way. I just wanna unblock >>> vfork() while still running this code. > > Would it make more sense to have a way to promote your vfork into a > fork when you hit these cases (I appreciate that fork on NOMMU has a much > higher performance cost as you start having to softmmu copy or swap > pages). It's not the performance cost, it's rewriting all the pointers. Without address translation, copying the existing mappings to a new range requires finding and adjusting every pointer to the old data, which you can do for the executable mappings in PIE* binaries, but tracking down all the pointers on the stack, heap, and in your global variables? Flaming pain. Making fork() work on nommu is basically the same problem as making garbage collection work in C on mmu. Thus those of us who defend vfork() from the people who don't understand why it exists periodically suggesting we remove it. > Alan Rob * or FDPIC, which is basically just PIE with 4 individually relocatable text/data/rodata/bss segments instead of one big mapping you relocate as a contiguous block; both work on nommu but fdpic can fit into more fragmented memory, and becauase the segments are independent it lets nommu share some segments between processes (code+rodata**) without sharing others (data and bss). That's why nommu can't run normal elf but can run PIE or FDPIC binaries. Or binflt which is the old a.out version. ** Don't ask me what happens when rodata contains a constant pointer to a bss or data object. I'm guessing the compiler Does A Thing. Ask Rich Felker?