qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas@t-8ch.de>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-devel@nongnu.org, "Thomas Weißschuh" <thomas@t-8ch.de>
Subject: [PATCH v2 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
Date: Sun, 07 Jan 2024 15:01:54 +0100	[thread overview]
Message-ID: <20240107-qemu-user-dumpable-v2-2-54e3bcfc00c9@t-8ch.de> (raw)
In-Reply-To: <20240107-qemu-user-dumpable-v2-0-54e3bcfc00c9@t-8ch.de>

A process can opt-out of coredump creation by calling
prctl(PR_SET_DUMPABLE, 0).
linux-user passes this call from the guest through to the
operating system.
From there it can be read back again to avoid creating coredumps from
qemu-user itself if the guest chose so.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
 linux-user/elfload.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 74c9ecda1806..956cb3ae2da5 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2,6 +2,7 @@
 #include "qemu/osdep.h"
 #include <sys/param.h>
 
+#include <sys/prctl.h>
 #include <sys/resource.h>
 #include <sys/shm.h>
 
@@ -4667,6 +4668,10 @@ static int elf_core_dump(int signr, const CPUArchState *env)
     init_note_info(&info);
 
     errno = 0;
+
+    if (prctl(PR_GET_DUMPABLE) == 0)
+        return 0;
+
     if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0)
         return 0;
 

-- 
2.43.0



  parent reply	other threads:[~2024-01-07 14:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07 14:01 [PATCH v2 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
2024-01-07 14:01 ` [PATCH v2 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
2024-01-07 14:01 ` Thomas Weißschuh [this message]
2024-01-09 21:33 ` [PATCH v2 0/2] linux-user: two fixes to coredump generation Richard Henderson
2024-01-09 21:59   ` Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240107-qemu-user-dumpable-v2-2-54e3bcfc00c9@t-8ch.de \
    --to=thomas@t-8ch.de \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).