qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>
Subject: [PULL 3/8] linux-user: handle /proc/self/exe with execve() syscall
Date: Tue, 25 Oct 2022 09:36:01 +0200	[thread overview]
Message-ID: <20221025073606.3114355-4-laurent@vivier.eu> (raw)
In-Reply-To: <20221025073606.3114355-1-laurent@vivier.eu>

If path is /proc/self/exe, use the executable path
provided by exec_path.

Don't use execfd as it is closed by loader_exec() and otherwise
will survive to the exec() syscall and be usable child process.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20220927124357.688536-2-laurent@vivier.eu>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ad06ec7bd54c..a7a29091c91e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8860,7 +8860,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
              * before the execve completes and makes it the other
              * program's problem.
              */
-            ret = get_errno(safe_execve(p, argp, envp));
+            if (is_proc_myself(p, "exe")) {
+                ret = get_errno(safe_execve(exec_path, argp, envp));
+            } else {
+                ret = get_errno(safe_execve(p, argp, envp));
+            }
             unlock_user(p, arg1, 0);
 
             goto execve_end;
-- 
2.37.3



  parent reply	other threads:[~2022-10-25  8:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  7:35 [PULL 0/8] Linux user for 7.2 patches Laurent Vivier
2022-10-25  7:35 ` [PULL 1/8] linux-user: Fix more MIPS n32 syscall ABI issues Laurent Vivier
2022-10-25  7:36 ` [PULL 2/8] linux-user: fix pidfd_send_signal() Laurent Vivier
2022-10-25  7:36 ` Laurent Vivier [this message]
2022-10-25  7:36 ` [PULL 4/8] linux-user: don't use AT_EXECFD in do_openat() Laurent Vivier
2022-10-25  7:36 ` [PULL 5/8] linux-user: add more compat ioctl definitions Laurent Vivier
2022-10-25  7:36 ` [PULL 6/8] linux-user: remove conditionals for many fs.h ioctls Laurent Vivier
2022-10-25  7:36 ` [PULL 7/8] linux-user: Implement faccessat2 Laurent Vivier
2022-10-25  7:36 ` [PULL 8/8] linux-user: Add guest memory layout to exception dump Laurent Vivier
2022-10-26 14:01 ` [PULL 0/8] Linux user for 7.2 patches Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221025073606.3114355-4-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).