Received: from eggs.gnu.org ([140.186.70.92]:39188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLgPR-0005PQ-V4 for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLgPQ-0005Ms-P2 for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:37 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53013 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLgPQ-0005Mi-HF for qemu-devel@nongnu.org; Wed, 02 Nov 2011 15:23:36 -0400 From: Alexander Graf Date: Wed, 2 Nov 2011 20:23:26 +0100 Message-Id: <1320261806-13194-6-git-send-email-agraf@suse.de> In-Reply-To: <1320261806-13194-5-git-send-email-agraf@suse.de> References: <1320261806-13194-1-git-send-email-agraf@suse.de> <1320261806-13194-2-git-send-email-agraf@suse.de> <1320261806-13194-3-git-send-email-agraf@suse.de> <1320261806-13194-4-git-send-email-agraf@suse.de> <1320261806-13194-5-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 5/5] linux-user: fake /proc/self/auxv List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: adrian@suse.de, riku.voipio@iki.fi Gtk tries to read /proc/self/auxv to find its auxv table instead of taking it from its own program memory space. However, when running with linux-user, we see the host's auxv which clearly exposes wrong information. so let's instead expose the guest memory backed auxv tables via /proc/self/auxv as well. Signed-off-by: Alexander Graf --- linux-user/syscall.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index aaecf53..6061ef8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4639,6 +4639,35 @@ static int open_self_stat(void *cpu_env, int fd) return 0; } +static int open_self_auxv(void *cpu_env, int fd) +{ + TaskState *ts = ((CPUState *)cpu_env)->opaque; + abi_ulong auxv = ts->info->saved_auxv; + abi_ulong len = ts->info->auxv_len; + char *ptr; + + /* + * Auxiliary vector is stored in target process stack. + * read in whole auxv vector and copy it to file + */ + ptr = lock_user(VERIFY_READ, auxv, len, 0); + if (ptr != NULL) { + while (len > 0) { + ssize_t r; + r = write(fd, ptr, len); + if (r <= 0) { + break; + } + len -= r; + ptr += r; + } + lseek(fd, 0, SEEK_SET); + unlock_user(ptr, auxv, len); + } + + return 0; +} + static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) { struct fake_open { @@ -4649,6 +4678,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) static const struct fake_open fakes[] = { { "/proc/self/maps", open_self_maps }, { "/proc/self/stat", open_self_stat }, + { "/proc/self/auxv", open_self_auxv }, { NULL, NULL } }; -- 1.6.0.2