From patchwork Fri Feb 3 14:49:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 139410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D1406104792 for ; Sat, 4 Feb 2012 03:05:39 +1100 (EST) Received: from localhost ([::1]:40590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKTE-000167-L2 for incoming@patchwork.ozlabs.org; Fri, 03 Feb 2012 09:50:36 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSM-0007tx-VC for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtKSE-0001UG-Vw for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:42 -0500 Received: from afflict.kos.to ([92.243.29.197]:49800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtKSE-0001TV-I5 for qemu-devel@nongnu.org; Fri, 03 Feb 2012 09:49:34 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id 4E72926533; Fri, 3 Feb 2012 14:49:32 +0000 (UTC) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 3 Feb 2012 16:49:19 +0200 Message-Id: <257450ee59fd7e781cb4e2316ddc845c40b9fc42.1328280144.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 92.243.29.197 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 06/19] linux-user: fake /proc/self/auxv X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alexander Graf 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 Signed-off-by: Riku Voipio --- 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 5a5fdac..c6bfcd8 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 } };