[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD
From: |
Richard Henderson |
Subject: |
[PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD |
Date: |
Tue, 30 Jul 2024 11:12:00 +1000 |
From: Vivian Wang <uwu@dram.page>
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Fixes: 0b959cf5e4cc ("linux-user: Use qemu_getauxval for AT_EXECFD")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2448
Message-ID: <20240723100545.405476-3-uwu@dram.page>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
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));
--
2.43.0
- [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/29
- [PULL 2/5] util/getauxval: Ensure setting errno if not found, Richard Henderson, 2024/07/29
- [PATCH for-9.1] tests/vm/openbsd: Install tomli, Richard Henderson, 2024/07/29
- [PULL 1/5] target/rx: Use target_ulong for address in LI, Richard Henderson, 2024/07/29
- [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD,
Richard Henderson <=
- [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD, Richard Henderson, 2024/07/29
- [PULL 5/5] linux-user: open_self_stat: Implement num_threads, Richard Henderson, 2024/07/29
- Re: [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/30