LWN: Comments on "Running code within another process's address space" https://lwn.net/Articles/852662/ This is a special feed containing comments posted to the individual LWN article titled "Running code within another process's address space". en-us Thu, 16 Oct 2025 09:51:26 +0000 Thu, 16 Oct 2025 09:51:26 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Some questions on Running code within another process's address space https://lwn.net/Articles/854114/ https://lwn.net/Articles/854114/ avagin <div class="FormattedComment"> <font class="QuotedText">&gt; 2) the caller resumes execution by jumping to the IP specified in `uctx` in the target&#x27;s address space; and the caller somehow gets back to the original context in the original address space when the target [makes a syscall / gets a signal].</font><br> <p> I would rephrase this:<br> <p> 2) the caller resumes execution by jumping to the IP specified in `uctx` in the target&#x27;s address space; and the caller somehow gets back to the original context in the original address space when it makes a syscall or gets a signal.<br> <p> The target process is used only to grub its address space. process_vm_exec doesn&#x27;t stop it and doesn&#x27;t change its state (registers, signals, fpu, etc).<br> <p> There are a few examples, I think they can help to understand how this works:<br> <a href="https://lwn.net/ml/linux-kernel/20210414055217.543246-5-avagin@gmail.com/">https://lwn.net/ml/linux-kernel/20210414055217.543246-5-a...</a><br> </div> Fri, 23 Apr 2021 05:18:04 +0000 Running code within another process's address space https://lwn.net/Articles/854009/ https://lwn.net/Articles/854009/ avagin <div class="FormattedComment"> Yes, we will need to create memory mappings. You can look at CRIU how it injects a parasite code into a process.<br> </div> Thu, 22 Apr 2021 16:50:53 +0000 Running code within another process's address space https://lwn.net/Articles/853847/ https://lwn.net/Articles/853847/ alkbyby <div class="FormattedComment"> It is indeed nifty to have such &quot;immediate signal&quot; facility within same address space. And assuming it will be used with sigmask set to block everything, it looks robust. Even delivering another such &quot;signal&quot; when one is already running (assuming the caller provides the stack in both cases which seems reasonable anyways) would work. I assume things like backtraces would work too, as this facility could use same sigreturn trampoline stuff as real signals.<br> <p> One particularly nice feature of this is that it is entirely compatible with all kinds of libraries. I.e. today libraries are essentially unable to use signals because it is ~impossible to arbitrate between libraries who is using which signal number. When there are no signal numbers or any state (e.g. altstack, sigaction) involved in first place, it looks like there no any kinds compatibility trouble.<br> <p> Another thing that would be nifty is being able to somehow specify not saving/restoring huge simd states to enable cheaper or more perf-sensitive usages of this facility (e.g. garbage collectors might choose to use it too), and to save stack. It seems inevitable that safe usage of this facility requires caller to allocate stack for each thread&#x27;s &quot;remote call&quot; and not having to bother about simd registers would save nontrivial number of bytes.<br> <p> </div> Thu, 22 Apr 2021 02:01:46 +0000 Running code within another process's address space https://lwn.net/Articles/853448/ https://lwn.net/Articles/853448/ jnewsome <div class="FormattedComment"> As someone working on a process sandbox/simulator/emulator &lt;<a href="http://shadow.github.io/">http://shadow.github.io/</a>&gt;, this looks super-exciting! We&#x27;re in the process now of moving from LD_PRELOAD-based interposition to ptrace. This simplifies a lot of things and is more robust, but is a significant performance hit. AFAICT we&#x27;d be able to switch over from ptrace to this new API without much work.<br> </div> Mon, 19 Apr 2021 16:54:00 +0000 Running code within another process's address space https://lwn.net/Articles/853163/ https://lwn.net/Articles/853163/ pm215 <div class="FormattedComment"> I would have thought that the correct way to solve &quot;implementing POSIX semantics for setuid() purely in userspace is somewhere between tricky and impossible&quot; (the glibc machinery for it is pretty gnarly) is &quot;implement a new kernel syscall that provides the whole-process semantics&quot;. The kernel is in a much better position to be able to do that than userspace ever will be. I&#x27;m mildly surprised that nobody&#x27;s ever had a go at it.<br> <p> </div> Sat, 17 Apr 2021 15:09:28 +0000 Some questions on Running code within another process's address space https://lwn.net/Articles/853133/ https://lwn.net/Articles/853133/ dongmk <div class="FormattedComment"> Thanks for your reply. :) But I find that it&#x27;s more complex than I thought earlier, and I am getting more confused.<br> <p> It may be helpful to confirm what the caller will do during `process_vm_exec`; here are two possibilities:<br> <p> 1) the caller blocks until the target [makes a syscall / gets a signal];<br> 2) the caller resumes execution by jumping to the IP specified in `uctx` in the target&#x27;s address space; and the caller somehow gets back to the original context in the original address space when the target [makes a syscall / gets a signal].<br> <p> For 1), emmm, there seems to be no `exec` effect since the original address space is restored when `process_vm_exec` returns; the caller simply blocks to wait for the target&#x27;s syscall/signal.<br> <p> For 2), a new control flow seems to have emerged after `process_vm_exec`, and the new control flow is terminated (at any time) upon the target&#x27;s syscall/signal.<br> </div> Sat, 17 Apr 2021 10:57:55 +0000 Some questions on Running code within another process's address space https://lwn.net/Articles/853129/ https://lwn.net/Articles/853129/ smurf <div class="FormattedComment"> <font class="QuotedText">&gt; &gt; that execution will continue until the **process** either makes a system call or receives a signal.</font><br> <p> <font class="QuotedText">&gt; Is this **process** the calling process or the target process? Or both?</font><br> <p> Umm, the target of course. When the target does [ make a syscall / gets a signal ], the system call returns, as described in the text. It obviously cannot do that if the caller continues execution in any way.<br> </div> Sat, 17 Apr 2021 09:23:43 +0000 Running code within another process's address space https://lwn.net/Articles/853128/ https://lwn.net/Articles/853128/ flussence <div class="FormattedComment"> Surely it should be called process_vm_exec*v*? :)<br> </div> Sat, 17 Apr 2021 09:15:21 +0000 Some questions on Running code within another process's address space https://lwn.net/Articles/853122/ https://lwn.net/Articles/853122/ dongmk <div class="FormattedComment"> Thanks for your nice article! The `process_vm_exec` system call is interesting, and I get some questions while reading the article.<br> <p> 1. If I understand correctly, the current `process_vm_exec` can only execute code that is already in the target process&#x27;s address space, which could be inconvenient for tasks such as inspecting the address space content.<br> In other words, the calling process needs to inject the code to the target (perhaps by `process_vm_writev`) before it invokes `process_vm_exec` to execute the injected code.<br> <p> Or does `process_vm_exec` provide some mechanisms to &quot;bring&quot; its own code to the switched address space?<br> <p> 2.<br> <p> <font class="QuotedText">&gt; that execution will continue until the **process** either makes a system call or receives a signal.</font><br> <p> Is this **process** the calling process or the target process? Or both?<br> <p> Will the target process (and threads in the target process) pause its execution upon the system call?<br> If so, how could the calling process resume the target&#x27;s execution?<br> If not, the calling process could miss some system calls made by the target, right?<br> <p> 3. I think things will be complicated when there are multiple threads in the calling process.<br> For example, when one thread calls `process_vm_exec` to switch the address space, other threads will run in the &quot;wrong address space&quot; and fail.<br> <p> Sorry for asking so many questions.<br> </div> Sat, 17 Apr 2021 05:57:38 +0000 Solaris-style Doors https://lwn.net/Articles/853102/ https://lwn.net/Articles/853102/ CChittleborough The <a href="http://www.rampant.org/doors/index.html">Linux port</a> was only “alpha quality”, and sadly work on it seems to have stopped in 2003. <p> The <a href="https://en.wikipedia.org/wiki/Doors_(computing)">Doors facility</a> needs both (1) kernel support and (2) a non-trivial user-space library. Door servers need that library to manage a thread pool in ways that almost require tight integration with the threads library. This is much easier when one organization produces both the kernel and the core libraries than in the Linux community. <p> (Full disclosure: I created that Wikipedia article.) Sat, 17 Apr 2021 01:26:50 +0000 Running code within another process's address space https://lwn.net/Articles/853104/ https://lwn.net/Articles/853104/ Cyberax <div class="FormattedComment"> Can we just get a file-decriptor based process API? Then the need to inject stuff into other processes would be severely reduced.<br> </div> Sat, 17 Apr 2021 00:47:47 +0000 Running code within another process's address space https://lwn.net/Articles/853095/ https://lwn.net/Articles/853095/ roc <div class="FormattedComment"> Remote system calls often need parameters (both in and out) in memory. If the target task is running, how do you guarantee with PROCESS_VM_EXEC_SYSCALL that any memory changes you make aren&#x27;t overwritten by the running task? You won&#x27;t be able to use the stack for example. Would you have to remote-sycall an mmap/munmap to allocate dedicated memory for your parameters?<br> </div> Sat, 17 Apr 2021 00:02:21 +0000 Running code within another process's address space https://lwn.net/Articles/853055/ https://lwn.net/Articles/853055/ luto <div class="FormattedComment"> setuid could be solved by a new syscall. The error handling might be nontrivial, but it’s doable.<br> </div> Fri, 16 Apr 2021 20:13:33 +0000 Running code within another process's address space https://lwn.net/Articles/853033/ https://lwn.net/Articles/853033/ klbrun <div class="FormattedComment"> Whatever happened to the Sun Microsystems Solaris door? Per Wikipedia, a port was made for Linux 2.4.18 in 2003.<br> </div> Fri, 16 Apr 2021 17:50:32 +0000 Running code within another process's address space https://lwn.net/Articles/853025/ https://lwn.net/Articles/853025/ josh <div class="FormattedComment"> I do wonder if problems like the setuid issue could be solved by io_uring and a &quot;run this on behalf of&quot; mechanism that allows one thread to submit items into an io_uring that runs in the context of another thread.<br> </div> Fri, 16 Apr 2021 16:46:44 +0000 Running code within another process's address space https://lwn.net/Articles/853007/ https://lwn.net/Articles/853007/ rvolgers <div class="FormattedComment"> Just as io_uring has finally settled on a sane context management mechanism for its worker threads, a new fundamentally broken way to mix-and-match process contexts is being invented. Marvelous.<br> </div> Fri, 16 Apr 2021 15:58:21 +0000