* [PATCH v3 0/2] linux-user: two fixes to coredump generation
@ 2024-01-20 21:45 Thomas Weißschuh
2024-01-20 21:45 ` [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
2024-01-20 21:45 ` [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-20 21:45 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh, Richard Henderson
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
Changes in v3:
- Add braces to if statements
- Add Reviewed-by from Richard
- Link to v2: https://lore.kernel.org/r/20240107-qemu-user-dumpable-v2-0-54e3bcfc00c9@t-8ch.de
Changes in v2:
- Rebase on 8.2 master
- Resend after closed tree and holidays
- Link to v1: https://lore.kernel.org/r/20231115-qemu-user-dumpable-v1-0-edbe7f0fbb02@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 | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
base-commit: 3f2a357b95845ea0bf7463eff6661e43b97d1afc
change-id: 20231115-qemu-user-dumpable-d499c0396103
Best regards,
--
Thomas Weißschuh <thomas@t-8ch.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit
2024-01-20 21:45 [PATCH v3 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
@ 2024-01-20 21:45 ` Thomas Weißschuh
2024-01-22 11:42 ` Philippe Mathieu-Daudé
2024-01-20 21:45 ` [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-20 21:45 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh, Richard Henderson
Should getrlimit() fail the value of dumpsize.rlimit_cur may not be
initialized. Avoid reading garbage data by checking the return value of
getrlimit.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
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 cf9e74468b11..c5968719380a 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4667,9 +4667,9 @@ 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.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
2024-01-20 21:45 [PATCH v3 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
2024-01-20 21:45 ` [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
@ 2024-01-20 21:45 ` Thomas Weißschuh
2024-01-22 11:41 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-20 21:45 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh, Richard Henderson
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.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
linux-user/elfload.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c5968719380a..daf7ef843564 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,11 @@ 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
2024-01-20 21:45 ` [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
@ 2024-01-22 11:41 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-22 11:41 UTC (permalink / raw)
To: Thomas Weißschuh, Laurent Vivier; +Cc: qemu-devel, Richard Henderson
On 20/1/24 22:45, Thomas Weißschuh wrote:
> 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.
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
> ---
> linux-user/elfload.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit
2024-01-20 21:45 ` [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
@ 2024-01-22 11:42 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-22 11:42 UTC (permalink / raw)
To: Thomas Weißschuh, Laurent Vivier; +Cc: qemu-devel, Richard Henderson
On 20/1/24 22:45, Thomas Weißschuh wrote:
> Should getrlimit() fail the value of dumpsize.rlimit_cur may not be
> initialized. Avoid reading garbage data by checking the return value of
> getrlimit.
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
> ---
> linux-user/elfload.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-22 11:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-20 21:45 [PATCH v3 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
2024-01-20 21:45 ` [PATCH v3 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
2024-01-22 11:42 ` Philippe Mathieu-Daudé
2024-01-20 21:45 ` [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
2024-01-22 11:41 ` 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).