qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] linux-user/elfload: Two Coverity fixes
@ 2024-03-05 23:39 Richard Henderson
  2024-03-05 23:39 ` [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
  2024-03-05 23:39 ` [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2024-03-05 23:39 UTC (permalink / raw)
  To: qemu-devel

Only the second one is serious, but let's fix both.

r~

Richard Henderson (2):
  linux-user/elfload: Don't close an unopened file descriptor
  linux-user/elfload: Fully initialize struct target_elf_prpsinfo

 linux-user/elfload.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

-- 
2.34.1



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

* [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor
  2024-03-05 23:39 [PATCH 0/2] linux-user/elfload: Two Coverity fixes Richard Henderson
@ 2024-03-05 23:39 ` Richard Henderson
  2024-03-06  6:43   ` Philippe Mathieu-Daudé
  2024-03-05 23:39 ` [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-03-05 23:39 UTC (permalink / raw)
  To: qemu-devel

Fixes Coverity CID: 1534964
Fixes: 106f8da664 ("linux-user/elfload: Open core file after vma_init")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 0c299a7c15..8565b9520a 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4522,7 +4522,9 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     ret = -errno;
     mmap_unlock();
     cpu_list_unlock();
-    close(fd);
+    if (fd >= 0) {
+        close(fd);
+    }
     return ret;
 }
 #endif /* USE_ELF_CORE_DUMP */
-- 
2.34.1



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

* [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo
  2024-03-05 23:39 [PATCH 0/2] linux-user/elfload: Two Coverity fixes Richard Henderson
  2024-03-05 23:39 ` [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
@ 2024-03-05 23:39 ` Richard Henderson
  2024-03-06  6:44   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-03-05 23:39 UTC (permalink / raw)
  To: qemu-devel

Fixes Coverity CID: 1534962
Fixes: 243c4706625 ("linux-user/elfload: Write corefile elf header in one block")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 8565b9520a..a9a6f55d6e 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4204,7 +4204,14 @@ static void fill_prpsinfo_note(void *data, const TaskState *ts)
      * may well have higher alignment requirements, fill locally and
      * memcpy to the destination afterward.
      */
-    struct target_elf_prpsinfo psinfo;
+    struct target_elf_prpsinfo psinfo = {
+        .pr_pid = getpid(),
+        .pr_ppid = getppid(),
+        .pr_pgrp = getpgrp(),
+        .pr_sid = getsid(0),
+        .pr_uid = getuid(),
+        .pr_gid = getgid(),
+    };
     char *base_filename;
     size_t len;
 
@@ -4217,13 +4224,6 @@ static void fill_prpsinfo_note(void *data, const TaskState *ts)
         }
     }
 
-    psinfo.pr_pid = getpid();
-    psinfo.pr_ppid = getppid();
-    psinfo.pr_pgrp = getpgrp();
-    psinfo.pr_sid = getsid(0);
-    psinfo.pr_uid = getuid();
-    psinfo.pr_gid = getgid();
-
     base_filename = g_path_get_basename(ts->bprm->filename);
     /*
      * Using strncpy here is fine: at max-length,
-- 
2.34.1



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

* Re: [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor
  2024-03-05 23:39 ` [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
@ 2024-03-06  6:43   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-03-06  6:43 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 6/3/24 00:39, Richard Henderson wrote:
> Fixes Coverity CID: 1534964
> Fixes: 106f8da664 ("linux-user/elfload: Open core file after vma_init")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/elfload.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




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

* Re: [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo
  2024-03-05 23:39 ` [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
@ 2024-03-06  6:44   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-03-06  6:44 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 6/3/24 00:39, Richard Henderson wrote:
> Fixes Coverity CID: 1534962
> Fixes: 243c4706625 ("linux-user/elfload: Write corefile elf header in one block")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/elfload.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

end of thread, other threads:[~2024-03-06  6:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05 23:39 [PATCH 0/2] linux-user/elfload: Two Coverity fixes Richard Henderson
2024-03-05 23:39 ` [PATCH 1/2] linux-user/elfload: Don't close an unopened file descriptor Richard Henderson
2024-03-06  6:43   ` Philippe Mathieu-Daudé
2024-03-05 23:39 ` [PATCH 2/2] linux-user/elfload: Fully initialize struct target_elf_prpsinfo Richard Henderson
2024-03-06  6:44   ` Philippe Mathieu-Daudé

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).