qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs
@ 2021-04-13 20:58 Ilya Leoshkevich
  2021-04-13 21:03 ` no-reply
  2021-05-15 19:59 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2021-04-13 20:58 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Christian Borntraeger, qemu-devel, 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 `<garbage>`

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 <iii@linux.ibm.com>
---
 linux-user/elfload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 4e45bd1539..cffcebfe45 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3662,10 +3662,10 @@ 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)
-- 
2.29.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs
  2021-04-13 20:58 [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs Ilya Leoshkevich
@ 2021-04-13 21:03 ` no-reply
  2021-05-15 19:59 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2021-04-13 21:03 UTC (permalink / raw)
  To: iii; +Cc: borntraeger, laurent, iii, qemu-devel

Patchew URL: https://patchew.org/QEMU/20210413205814.22821-1-iii@linux.ibm.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210413205814.22821-1-iii@linux.ibm.com
Subject: [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20210413205814.22821-1-iii@linux.ibm.com -> patchew/20210413205814.22821-1-iii@linux.ibm.com
Switched to a new branch 'test'
01536fa linux-user/elfload: fix filling psinfo->pr_psargs

=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement
#35: FILE: linux-user/elfload.c:3635:
+    if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_strings, len))
[...]

total: 1 errors, 0 warnings, 12 lines checked

Commit 01536fa0c80b (linux-user/elfload: fix filling psinfo->pr_psargs) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210413205814.22821-1-iii@linux.ibm.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs
  2021-04-13 20:58 [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs Ilya Leoshkevich
  2021-04-13 21:03 ` no-reply
@ 2021-05-15 19:59 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2021-05-15 19:59 UTC (permalink / raw)
  To: Ilya Leoshkevich; +Cc: Christian Borntraeger, qemu-devel

Le 13/04/2021 à 22:58, Ilya Leoshkevich a écrit :
> 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 `<garbage>`
> 
> 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 <iii@linux.ibm.com>
> ---
>  linux-user/elfload.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 4e45bd1539..cffcebfe45 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -3662,10 +3662,10 @@ 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)
> 


Applied to my linux-user-for-6.1 branch.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-15 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 20:58 [PATCH] linux-user/elfload: fix filling psinfo->pr_psargs Ilya Leoshkevich
2021-04-13 21:03 ` no-reply
2021-05-15 19:59 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).