qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: qemu-devel@nongnu.org, iii@linux.ibm.com, laurent@vivier.eu
Subject: Re: linux-user: Add option to run `execve`d programs through QEMU
Date: Thu, 7 Nov 2024 09:42:22 +0000	[thread overview]
Message-ID: <5d8ecf29-aed5-4e3e-9b4c-f3b5e5bcdef8@linaro.org> (raw)
In-Reply-To: <CAFUsyf+OjfFVJ80ZwL8SovH80nTA4qpNyr2Nh7uUW90jZifSGQ@mail.gmail.com>

On 11/6/24 23:49, Noah Goldstein wrote:
> On Wed, Nov 6, 2024 at 3:30 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>>
>> On Wed, Nov 6, 2024 at 3:10 PM Richard Henderson
>> <richard.henderson@linaro.org> wrote:
>>>
>>> On 11/6/24 18:13, Noah Goldstein wrote:
>>>> Question about impl regarding handling of `-execfd` with/without a program name.
>>>>
>>>> 1) `-execfd` + program name ie: `qemu -execfd <some_fd> ls -a`.
>>>> 2) `-execfd` without program name i.e: `qemu -execfd <some_fd> -a`.
>>>>
>>>> Do you want to allow both of these? If you want to allow (1), what should
>>>> we use for `argv[0]`/`exec_path`. The program pass ("ls") or
>>>> `readlink(<some_fd>)`?
>>>
>>> The canonical response is, examine the kernel source.
>>> We're not implementing this in a vacuum, you're replicating execveat(2).
>>>
>>> I suspect the answer is (1), to be compared with
>>>
>>>       syscall(__NR_execveat, some_fd, "", &["ls", "-a"], env, AT_EMPTY_PATH);
>>
>> Err, I think the reference for '-execfd' is `fexecve`:
>> https://man7.org/linux/man-pages/man3/fexecve.3.html
>>
>> Which doesn't take a path. So I guess we just interpret the "ls" as
>> argv[0] but not
>> as "exec_path".
> 
> One more point, what should the behavior be if we have
> AT_EXECFD from binfmt-misc?

You mean precedence of AT_EXECFD vs the command-line option?

Arbitrary, since it would be a usage error to have both.  You'd have to do something silly 
with the binfmt-misc rule for that to happen.

Perhaps

static int execfd = -1;
// option processing
// main

     if (execfd < 0) {
         errno = 0;
         execfd = qemu_getauxval(AT_EXECFD);
         if (errno != 0) {
             execfd = open(...);
         }
     }

just because that's a simple change to what's currently present.


r~


  reply	other threads:[~2024-11-07  9:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 22:36 [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU Noah Goldstein
2024-08-30 22:37 ` Noah Goldstein
2024-09-10 22:06   ` Noah Goldstein
2024-09-24 14:43     ` Noah Goldstein
2024-10-02  8:08 ` Ilya Leoshkevich
2024-10-02 14:05   ` Noah Goldstein
2024-10-02 16:39     ` Ilya Leoshkevich
2024-10-02 16:42       ` Noah Goldstein
2024-10-11 18:14         ` Noah Goldstein
2024-10-22 22:06           ` Noah Goldstein
2024-10-29 14:51             ` Noah Goldstein
2024-10-02 14:08   ` Laurent Vivier
2024-10-02 14:25     ` Ilya Leoshkevich
2024-10-02 14:44       ` Noah Goldstein
2024-10-02 14:53         ` Ilya Leoshkevich
2024-10-02 15:10           ` Noah Goldstein
2024-10-02 16:14             ` Ilya Leoshkevich
2024-10-02 16:24               ` Noah Goldstein
2024-10-02 16:35                 ` Ilya Leoshkevich
2024-10-02 16:36                   ` Noah Goldstein
2024-10-02 15:59           ` Laurent Vivier
2024-10-02 14:50 ` [PATCH v2] " Noah Goldstein
2024-10-29 15:23 ` [PATCH v1] " Alex Bennée
2024-10-29 15:27   ` Noah Goldstein
2024-10-30 14:10 ` Noah Goldstein
2024-10-30 14:11   ` Noah Goldstein
2024-11-05 11:37   ` Richard Henderson
2024-11-05 23:48     ` Noah Goldstein
2024-11-05 23:54       ` Noah Goldstein
2024-11-06  9:38         ` Richard Henderson
2024-11-06 17:03           ` Noah Goldstein
2024-11-06 17:25             ` Richard Henderson
2024-11-06 17:53               ` Noah Goldstein
2024-11-06 18:13                 ` Noah Goldstein
2024-11-06 21:10                   ` Richard Henderson
2024-11-06 21:30                     ` Noah Goldstein
2024-11-06 23:49                       ` Noah Goldstein
2024-11-07  9:42                         ` Richard Henderson [this message]
2024-11-07  9:29                       ` Richard Henderson

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=5d8ecf29-aed5-4e3e-9b4c-f3b5e5bcdef8@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=goldstein.w.n@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=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).