From: Richard Henderson <richard.henderson@linaro.org>
To: Vivian Wang <uwu@dram.page>, qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH 2/2] linux-user/main: Check errno when getting AT_EXECFD
Date: Tue, 23 Jul 2024 09:24:44 +1000 [thread overview]
Message-ID: <6438c625-89d6-48e7-be02-7b77f4090c0b@linaro.org> (raw)
In-Reply-To: <20240721090817.120888-3-uwu@dram.page>
On 7/21/24 19:08, Vivian Wang wrote:
> It's possible for AT_EXECFD to end up with a valid value of 0. Check
> errno when using qemu_getauxval instead of return value to handle this
> case.
>
> Not handling this case leads to a confusing condition where the
> executable ends up as fd 0, i.e. stdin.
>
> Signed-off-by: Vivian Wang <uwu@dram.page>
> Fixes: 0b959cf5e4cc ("linux-user: Use qemu_getauxval for AT_EXECFD")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2448
> ---
> linux-user/main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 7d3cf45fa9..8143a0d4b0 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -755,8 +755,9 @@ int main(int argc, char **argv, char **envp)
> /*
> * Manage binfmt-misc open-binary flag
> */
> + errno = 0;
> execfd = qemu_getauxval(AT_EXECFD);
> - if (execfd == 0) {
> + if (errno != 0) {
> execfd = open(exec_path, O_RDONLY);
> if (execfd < 0) {
> printf("Error while loading %s: %s\n", exec_path, strerror(errno));
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
prev parent reply other threads:[~2024-07-22 23:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-21 9:08 [PATCH 0/2] linux-user: Fix handling when AT_EXECFD is 0 Vivian Wang
2024-07-21 9:08 ` [PATCH 1/2] util/getauxval: Ensure setting errno if not found Vivian Wang
2024-07-22 0:18 ` Xingtao Yao (Fujitsu) via
2024-07-22 8:24 ` Vivian Wang
2024-07-22 9:26 ` Xingtao Yao (Fujitsu) via
2024-07-22 23:24 ` Richard Henderson
2024-07-21 9:08 ` [PATCH 2/2] linux-user/main: Check errno when getting AT_EXECFD Vivian Wang
2024-07-22 23:24 ` Richard Henderson [this message]
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=6438c625-89d6-48e7-be02-7b77f4090c0b@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=uwu@dram.page \
/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).