Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1726574 > unrolled thread
| Started by | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| First post | 2017-09-05 11:10 +0200 |
| Last post | 2017-09-08 23:20 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: execve(NULL, argv, envp) for nommu? Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-05 11:10 +0200
Re: execve(NULL, argv, envp) for nommu? Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-09-05 15:30 +0200
Re: execve(NULL, argv, envp) for nommu? Rob Landley <rob@landley.net> - 2017-09-06 03:20 +0200
Re: execve(NULL, argv, envp) for nommu? Rob Landley <rob@landley.net> - 2017-09-08 23:20 +0200
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Date | 2017-09-05 11:10 +0200 |
| Subject | Re: execve(NULL, argv, envp) for nommu? |
| Message-ID | <umi1P-Ly-5@gated-at.bofh.it> |
CC Oleg, lkml On Tue, Sep 5, 2017 at 9:34 AM, Rob Landley <rob@landley.net> 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
[toc] | [next] | [standalone]
| From | Alan Cox <gnomes@lxorguk.ukuu.org.uk> |
|---|---|
| Date | 2017-09-05 15:30 +0200 |
| Message-ID | <umm5r-38R-5@gated-at.bofh.it> |
| In reply to | #1726574 |
> > 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) > > 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). Alan
[toc] | [prev] | [next] | [standalone]
| From | Rob Landley <rob@landley.net> |
|---|---|
| Date | 2017-09-06 03:20 +0200 |
| Message-ID | <umxay-2mO-5@gated-at.bofh.it> |
| In reply to | #1726716 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Rob Landley <rob@landley.net> |
|---|---|
| Date | 2017-09-08 23:20 +0200 |
| Message-ID | <unyQW-46I-15@gated-at.bofh.it> |
| In reply to | #1727105 |
On 09/05/2017 08:12 PM, Rob Landley wrote: > On 09/05/2017 08:24 AM, Alan Cox wrote: >>>> 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. So is exec(NULL, argv, envp) a reasonable thing to want? Rob
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web