* [PATCH 0/2] linux-user: two fixes to coredump generation
@ 2023-11-15 16:37 Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2023-11-15 16:37 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
Thomas Weißschuh (2):
linux-user/elfload: test return value of getrlimit
linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
linux-user/elfload.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
base-commit: 9c673a41eefc50f1cb2fe3c083e7de842c7d276a
change-id: 20231115-qemu-user-dumpable-d499c0396103
Best regards,
--
Thomas Weißschuh <thomas@t-8ch.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] linux-user/elfload: test return value of getrlimit
2023-11-15 16:37 [PATCH 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
@ 2023-11-15 16:37 ` Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2023-11-15 16:37 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh
Should getrlimit() fail the value of dumpsize.rlimit_cur may not be
initialized. Avoid reading garbage data by checking the return value of
getrlimit.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
linux-user/elfload.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 4cd6891d7b6a..799fe8497346 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4667,8 +4667,7 @@ static int elf_core_dump(int signr, const CPUArchState *env)
init_note_info(&info);
errno = 0;
- getrlimit(RLIMIT_CORE, &dumpsize);
- if (dumpsize.rlim_cur == 0)
+ if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0)
return 0;
corefile = core_dump_filename(ts);
--
2.42.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
2023-11-15 16:37 [PATCH 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
@ 2023-11-15 16:37 ` Thomas Weißschuh
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2023-11-15 16:37 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh
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 799fe8497346..76d5740af0ca 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.42.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-15 16:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-15 16:37 [PATCH 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
2023-11-15 16:37 ` [PATCH 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
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).