From patchwork Mon May 17 18:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1479783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FkT1028qRz9s1l for ; Tue, 18 May 2021 04:58:12 +1000 (AEST) Received: from localhost ([::1]:37364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liiRM-00072Z-HR for incoming@patchwork.ozlabs.org; Mon, 17 May 2021 14:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihm6-00075H-3e for qemu-devel@nongnu.org; Mon, 17 May 2021 14:15:30 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:44031) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lihle-0004cc-9p for qemu-devel@nongnu.org; Mon, 17 May 2021 14:15:29 -0400 Received: from quad ([82.142.31.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MiMIY-1lEItz0r7G-00fP25; Mon, 17 May 2021 20:14:57 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 58/59] linux-user/elfload: fix filling psinfo->pr_psargs Date: Mon, 17 May 2021 20:14:23 +0200 Message-Id: <20210517181424.8093-59-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517181424.8093-1-laurent@vivier.eu> References: <20210517181424.8093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:+/At8f9TSNJZ0TGAWLYr9+ZJ+Wxk3Mn9EOcaa2PhcsDPEQzqclg w8fwxupAk+VlgftcyjUbXhFcZeCR6MS/3NXuIFQoXhA3V/jGERqJpaTEdUnyaR4sglvP70W dhd0Bxg7h8yrEQkGKrjiEm+djHFKd0zrkulHyOxORvuh44jFu1IwN7a1RldX2U+/Q5eU6Sw Jh764tSkDAsfyy435+dLQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ioU0sDOAAkk=:plq9aaFDwZd5NNKL1ggw+/ UL4R+9M7EdIq9OxHDGQ9ZWsv4bh3DyrGZjwdldW15z5kxW8+KiCG/RTd79TXTKLUz7QwGM45G M306oofBNDwAie4eZeA6bP1ojGWQQ6WlfMb7zi/3l/tpMAiaI+Djg2hbuS2+bL9aVOZyxA+ox ehc11XH8ftTdGxE0HsD42bmD6+MKp12tfqBU8OZ7+bdsFJpowLMB8aD/6f1tKS79L4RLevWvW LXvbuRuT09MeFZjgCfXRtWRMemwVz+tocfMN+ngcx72XyVX1EZIrMMkDq8bQ/xEnHNBOHaF+3 1Z3utdl0XRqYfwe/TVDfvnfuvoMCFx8zID2kS1vl3cs+5tXAVqWSOYWyxDQPL6r5xsEPhQmEZ b16xK8y4hU08m84QoGeDeeYZl7OWi3dv3I+YyhWD2jCgTJAM8Pasd8Xe8UV9GuSLsw37LRW9u fYFWdsUEyivGLyJ+NXxeTQO3NYYbP+Iub2O+XPkXpA4dE7lzrW/lMX851D6tIP66PPk1FJ/3Q 5UChMA82Ta4sjdf/jQB6z0= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Ilya Leoshkevich Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ilya Leoshkevich The current code dumps the memory between arg_start and arg_end, which contains the argv pointers. This results in the Core was generated by `` message when opening the core file in GDB. This is because the code is supposed to dump the actual arg strings. Fix by using arg_strings and env_strings instead of arg_start and arg_end. Signed-off-by: Ilya Leoshkevich Message-Id: <20210413205814.22821-1-iii@linux.ibm.com> [lv: add missing braces] Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 015eed1a27b4..9779263727ba 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3618,11 +3618,12 @@ static int fill_psinfo(struct target_elf_prpsinfo *psinfo, const TaskState *ts) (void) memset(psinfo, 0, sizeof (*psinfo)); - len = ts->info->arg_end - ts->info->arg_start; + len = ts->info->env_strings - ts->info->arg_strings; if (len >= ELF_PRARGSZ) len = ELF_PRARGSZ - 1; - if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_start, len)) + if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_strings, len)) { return -EFAULT; + } for (i = 0; i < len; i++) if (psinfo->pr_psargs[i] == 0) psinfo->pr_psargs[i] = ' ';