From: Laurent Vivier <laurent@vivier.eu>
To: Michael Vogt <mvogt@redhat.com>, qemu-devel@nongnu.org
Cc: Michael Vogt <michael.vogt@gmail.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH v6 1/1] linux-user: add openat2 support in linux-user
Date: Fri, 20 Sep 2024 11:33:22 +0200 [thread overview]
Message-ID: <a9e7b8b6-0d0e-4ed3-af82-4bcec665e52f@vivier.eu> (raw)
In-Reply-To: <65bb234d769980a3b10a655ed19f87966c714e06.1726817664.git.mvogt@redhat.com>
Le 20/09/2024 à 11:22, Michael Vogt a écrit :
> This commit adds support for the `openat2()` syscall in the
> `linux-user` userspace emulator.
>
> It is implemented by extracting a new helper `maybe_do_fake_open()`
> out of the exiting `do_guest_openat()` and share that with the
> new `do_guest_openat2()`. Unfortunately we cannot just make
> do_guest_openat2() a superset of do_guest_openat() because the
> openat2() syscall is stricter with the argument checking and
> will return an error for invalid flags or mode combinations (which
> open()/openat() will ignore).
>
> The implementation is similar to SYSCALL_DEFINE(openat2), i.e.
> a new `copy_struct_from_user()` is used that works the same
> as the kernels version to support backwards-compatibility
> for struct syscall argument.
>
> Instead of including openat2.h we create a copy of `open_how`
> as `open_how_ver0` to ensure that if the structure grows we
> can log a LOG_UNIMP warning.
>
> Note that in this commit using openat2() for a "faked" file in
> /proc will ignore the "resolve" flags. This is not great but it
> seems similar to the exiting behavior when openat() is called
> with a dirfd to "/proc". Here too the fake file lookup may
> not catch the special file because "realpath()" is used to
> determine if the path is in /proc. Alternatively to ignoring
> we could simply fail with `-TARGET_ENOSYS` (or similar) if
> `resolve` flags are passed and we found something that looks
> like a file in /proc that needs faking.
>
> Signed-off-by: Michael Vogt <mvogt@redhat.com>
> Buglink: https://github.com/osbuild/bootc-image-builder/issues/619
> ---
> linux-user/syscall.c | 108 +++++++++++++++++++++++++++++++++++++-
> linux-user/syscall_defs.h | 7 +++
> 2 files changed, 113 insertions(+), 2 deletions(-)
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
next prev parent reply other threads:[~2024-09-20 9:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 9:22 [PATCH v6 0/1] linux-user: add openat2 support in linux-user Michael Vogt
2024-09-20 9:22 ` [PATCH v6 1/1] " Michael Vogt
2024-09-20 9:33 ` Laurent Vivier [this message]
2024-09-22 7:25 ` 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=a9e7b8b6-0d0e-4ed3-af82-4bcec665e52f@vivier.eu \
--to=laurent@vivier.eu \
--cc=michael.vogt@gmail.com \
--cc=mvogt@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).