[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/15] linux-user: remove all traces of qemu from /pr
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 06/15] linux-user: remove all traces of qemu from /proc/self/cmdline |
Date: |
Wed, 31 May 2017 16:08:18 +0300 |
From: Andreas Schwab <address@hidden>
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 <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 47 +++++++----------------------------------------
1 file changed, 7 insertions(+), 40 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c8f6efc89c..909dde6de6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7358,52 +7358,19 @@ int host_to_target_waitstatus(int status)
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)
--
2.11.0
- [Qemu-devel] [PULL 00/15] Misc linux-user updates, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 02/15] linux-user: fix eventfd, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 01/15] linux-user: call fd_trans_target_to_host_data() for write(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 03/15] linux-user: fix fadvise64_64() on ppc, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 04/15] linux-user: fix inotify, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 05/15] linux-user: allocate heap memory for execve arguments, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 08/15] linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 09/15] linux-user: fix ssetmask() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 06/15] linux-user: remove all traces of qemu from /proc/self/cmdline,
riku . voipio <=
- [Qemu-devel] [PULL 07/15] linux-user: add strace for getuid(), gettid(), getppid(), geteuid(), riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 10/15] linux-user: fix mismatch of lock/unlock_user() invocations in rt_sigqueinfo() syscall, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 12/15] linux-user: add support for rt_tgsigqueueinfo() system call, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 13/15] linux-user: add rt_tgsigqueueinfo() strace, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 14/15] linux-user: fix inconsistent spaces in print_siginfo() output, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 11/15] linux-user: fix argument type declaration of rt_sigqueinfo() syscall, riku . voipio, 2017/05/31
- [Qemu-devel] [PULL 15/15] linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo(), riku . voipio, 2017/05/31