2017-04-28 13:47:25 +02:00
|
|
|
From 0206a322d7067b3b74c868f2d80e8dfb4c24de97 Mon Sep 17 00:00:00 2001
|
2016-11-07 19:10:23 +01:00
|
|
|
From: Andreas Schwab <schwab@suse.de>
|
|
|
|
Date: Wed, 28 Sep 2016 16:36:40 +0200
|
|
|
|
Subject: [PATCH] linux-user: remove all traces of qemu from /proc/self/cmdline
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Instead of post-processing the real contents use the remembered target
|
|
|
|
argv. That removes all traces of qemu, including command line options,
|
|
|
|
and handles QEMU_ARGV0.
|
|
|
|
|
|
|
|
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
|
---
|
|
|
|
linux-user/syscall.c | 47 +++++++----------------------------------------
|
|
|
|
1 file changed, 7 insertions(+), 40 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
2017-05-05 17:05:43 +02:00
|
|
|
index 78f0ea4c58..1e56583d63 100644
|
2016-11-07 19:10:23 +01:00
|
|
|
--- a/linux-user/syscall.c
|
|
|
|
+++ b/linux-user/syscall.c
|
2017-03-29 06:22:10 +02:00
|
|
|
@@ -7374,52 +7374,19 @@ int host_to_target_waitstatus(int status)
|
2016-11-07 19:10:23 +01:00
|
|
|
|
|
|
|
static int open_self_cmdline(void *cpu_env, int fd)
|
|
|
|
{
|
|
|
|
- int fd_orig = -1;
|
|
|
|
- bool word_skipped = false;
|
|
|
|
-
|
|
|
|
- fd_orig = open("/proc/self/cmdline", O_RDONLY);
|
|
|
|
- if (fd_orig < 0) {
|
|
|
|
- return fd_orig;
|
|
|
|
- }
|
|
|
|
+ CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env);
|
|
|
|
+ struct linux_binprm *bprm = ((TaskState *)cpu->opaque)->bprm;
|
|
|
|
+ int i;
|
|
|
|
|
|
|
|
- while (true) {
|
|
|
|
- ssize_t nb_read;
|
|
|
|
- char buf[128];
|
|
|
|
- char *cp_buf = buf;
|
|
|
|
+ for (i = 0; i < bprm->argc; i++) {
|
|
|
|
+ size_t len = strlen(bprm->argv[i]) + 1;
|
|
|
|
|
|
|
|
- nb_read = read(fd_orig, buf, sizeof(buf));
|
|
|
|
- if (nb_read < 0) {
|
|
|
|
- int e = errno;
|
|
|
|
- fd_orig = close(fd_orig);
|
|
|
|
- errno = e;
|
|
|
|
+ if (write(fd, bprm->argv[i], len) != len) {
|
|
|
|
return -1;
|
|
|
|
- } else if (nb_read == 0) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!word_skipped) {
|
|
|
|
- /* Skip the first string, which is the path to qemu-*-static
|
|
|
|
- instead of the actual command. */
|
|
|
|
- cp_buf = memchr(buf, 0, nb_read);
|
|
|
|
- if (cp_buf) {
|
|
|
|
- /* Null byte found, skip one string */
|
|
|
|
- cp_buf++;
|
|
|
|
- nb_read -= cp_buf - buf;
|
|
|
|
- word_skipped = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (word_skipped) {
|
|
|
|
- if (write(fd, cp_buf, nb_read) != nb_read) {
|
|
|
|
- int e = errno;
|
|
|
|
- close(fd_orig);
|
|
|
|
- errno = e;
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- return close(fd_orig);
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int open_self_maps(void *cpu_env, int fd)
|