Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751173AbdIEJBA (ORCPT ); Tue, 5 Sep 2017 05:01:00 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:38703 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750709AbdIEJA5 (ORCPT ); Tue, 5 Sep 2017 05:00:57 -0400 X-Google-Smtp-Source: ADKCNb4TonYakgmjYdY5PN6bagB5PmdRaM4S3NVN6qcPzP5VZlguiOxPf62gnzKO3a4E0NsagRNnL7L4GkBG1qjLiW4= MIME-Version: 1.0 In-Reply-To: <324c00d9-06a6-1fc5-83fe-5bd36d874501@landley.net> References: <324c00d9-06a6-1fc5-83fe-5bd36d874501@landley.net> From: Geert Uytterhoeven Date: Tue, 5 Sep 2017 11:00:55 +0200 X-Google-Sender-Auth: UHZ_NcXMSRfme2UXHvMistR0mWQ Message-ID: Subject: Re: execve(NULL, argv, envp) for nommu? To: Rob Landley Cc: Linux Embedded , Oleg Nesterov , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1461 Lines: 29 CC Oleg, lkml On Tue, Sep 5, 2017 at 9:34 AM, Rob Landley wrote: > For years I've wanted an execve() system call modification that let me > pass a NULL as the first argument to say "re-exec this program please". > Because on nommu you've got to exec something to unblock vfork(), and > daemons (or things like busybox and toybox) want to re-exec themselves. > I just hit this again trying to implement a nommu-friendly strace(): the > one on github doesn't SIGSTOP the child before the execve() of the > process to trace because vfork(), and just races and misses the first > few system calls on nommu instead...) > > The problem with exec /proc/self/exe is A) I haven't necessarily got > /proc mounted, B) in a chroot the original binary might not be in scope > 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... > > I'm aware there's a possible "but what if it was suid and it's already > dropped privileges" argument, and I'm fine with execve(NULL) not > honoring the suid bit if people feel that way. I just wanna unblock > vfork() while still running this code. (A way to detect I did this would > be great too, but the normal tweaking of argv[] or envp[] to let main > know we're a child still works.) > > Is there a _reason_ the kernel doesn't do this, or has nobody bothered > to code it up yet? > > Rob