qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Subject: Re: [PATCH v1] linux-user: Add option to run `execve`d programs through QEMU
Date: Wed, 02 Oct 2024 18:14:24 +0200	[thread overview]
Message-ID: <c2e3d873cee9d9548d632a5a27f4af06ce82bf88.camel@linux.ibm.com> (raw)
In-Reply-To: <CAFUsyfKddfkryMX3Jn+2uDrteHDDgdzrQ3A4k5oXNpHq2FG_Gw@mail.gmail.com>

On Wed, 2024-10-02 at 10:10 -0500, Noah Goldstein wrote:
> On Wed, Oct 2, 2024 at 9:53 AM Ilya Leoshkevich <iii@linux.ibm.com>
> wrote:
> > 
> > On Wed, 2024-10-02 at 09:44 -0500, Noah Goldstein wrote:
> > > On Wed, Oct 2, 2024 at 9:38 AM Ilya Leoshkevich
> > > <iii@linux.ibm.com>
> > > wrote:
> > > > 
> > > > On Wed, 2024-10-02 at 16:08 +0200, Laurent Vivier wrote:
> > > > > Le 02/10/2024 à 10:08, Ilya Leoshkevich a écrit :
> > > > > > On Fri, 2024-08-30 at 15:36 -0700, Noah Goldstein wrote:
> > > > > > > The new option '-qemu-children' makes it so that on
> > > > > > > `execve`
> > > > > > > the
> > > > > > > child
> > > > > > > process will be launch by the same `qemu` executable that
> > > > > > > is
> > > > > > > currently
> > > > > > > running along with its current commandline arguments.
> > > > > > > 
> > > > > > > The motivation for the change is to make it so that
> > > > > > > plugins
> > > > > > > running
> > > > > > > through `qemu` can continue to run on children.  Why not
> > > > > > > just
> > > > > > > `binfmt`?: Plugins can be desirable regardless of
> > > > > > > system/architecture
> > > > > > > emulation, and can sometimes be useful for elf files that
> > > > > > > can
> > > > > > > run
> > > > > > > natively. Enabling `binfmt` for all natively runnable elf
> > > > > > > files
> > > > > > > may
> > > > > > > not be desirable.
> > > > > > 
> > > > > > Another reason to have this is that one may not have root
> > > > > > permissions
> > > > > > to configure binfmt-misc.
> > > > > 
> > > > > A little note on that: binfmt_misc is now part of the user
> > > > > namespace
> > > > > (since linux v6.7), so you can
> > > > > configure binfmt_misc as a non root user in a given namepace.
> > > > > 
> > > > > There is helper to use it with unshare from util-linux, you
> > > > > can
> > > > > do
> > > > > things like that:
> > > > > 
> > > > >    With 'F' flag, load the interpreter from the initial
> > > > > namespace:
> > > > > 
> > > > >      $ /bin/qemu-m68k-static --version
> > > > >      qemu-m68k version 8.2.2 (qemu-8.2.2-1.fc40)
> > > > >      Copyright (c) 2003-2023 Fabrice Bellard and the QEMU
> > > > > Project
> > > > > developers
> > > > >      $ unshare --map-root-user --fork --pid
> > > > > --load-interp=":qemu-
> > > > > m68k:M::\\x7fELF\\x01\\x02\\x01\\x00\\x00\\x00\\x00\\x00\\x00
> > > > > \\x0
> > > > > 0\\x
> > > > > 00\\x00\\x00\\x02\\x00\\x04:\\xff\\xff\\xff\\xff\\xff\\xff\\x
> > > > > fe\\
> > > > > x00\
> > > > > \xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff:/
> > > > > bin/
> > > > > qemu
> > > > > -m68k-static:OCF"
> > > > > --root=chroot/m68k/sid
> > > > >      # QEMU_VERSION= ls
> > > > >      qemu-m68k version 8.2.2 (qemu-8.2.2-1.fc40)
> > > > >      Copyright (c) 2003-2023 Fabrice Bellard and the QEMU
> > > > > Project
> > > > > developers
> > > > >      # /qemu-m68k  --version
> > > > >      qemu-m68k version 8.0.50 (v8.0.0-340-gb1cff5e2da95)
> > > > >      Copyright (c) 2003-2022 Fabrice Bellard and the QEMU
> > > > > Project
> > > > > developers
> > > > > 
> > > > >    Without 'F' flag, from inside the namespace:
> > > > > 
> > > > >      $ unshare --map-root-user --fork --pid
> > > > > --load-interp=":qemu-
> > > > > m68k:M::\\x7fELF\\x01\\x02\\x01\\x00\\x00\\x00\\x00\\x00\\x00
> > > > > \\x0
> > > > > 0\\x
> > > > > 00\\x00\\x00\\x02\\x00\\x04:\\xff\\xff\\xff\\xff\\xff\\xff\\x
> > > > > fe\\
> > > > > x00\
> > > > > \xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff:/
> > > > > qemu
> > > > > -
> > > > > m68k:OC"
> > > > > --root=chroot/m68k/sid
> > > > >      # QEMU_VERSION= ls
> > > > >      qemu-m68k version 8.0.50 (v8.0.0-340-gb1cff5e2da95)
> > > > >      Copyright (c) 2003-2022 Fabrice Bellard and the QEMU
> > > > > Project
> > > > > developers
> > > > >      # /qemu-m68k  --version
> > > > >      qemu-m68k version 8.0.50 (v8.0.0-340-gb1cff5e2da95)
> > > > >      Copyright (c) 2003-2022 Fabrice Bellard and the QEMU
> > > > > Project
> > > > > developers
> > > > > 
> > > > > Thanks,
> > > > > Laurent
> > > > > 
> > > > 
> > > > Thanks for posting this, I wasn't aware of this feature and it
> > > > looks
> > > > really useful.
> > > > 
> > > > IIUC it also resolves the main problem this patch is dealing
> > > > with:
> > > 
> > > I might misunderstand, but I don't think it does in the sense
> > > that it still might not be desirable to use the same qemu flags
> > > for the entire class of executables.
> > > 
> > > I.e the original motivating case was wanting to attach
> > > some plugins to a process and its children and AFAICT
> > > binfmt still doesn't give that level of control.
> > 
> > I think if you start a process in a user namespace, which has a
> > binfmt_misc handler for a certain class of binaries, then this
> > handler
> > will affect only this process and its children, and not the rest of
> > the
> > system.
> 
> It won't also affect other binaries in the user namespace?

It would, but you should be able to create a user namespace just
for your program. It should also be possible to nest user namespaces.

> > > >   Enabling `binfmt` for all natively runnable elf files may
> > > >   not be desirable.



  reply	other threads:[~2024-10-02 16:15 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 [this message]
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
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=c2e3d873cee9d9548d632a5a27f4af06ce82bf88.camel@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=goldstein.w.n@gmail.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).