* [PATCH v2 0/2] linux-user: two fixes to coredump generation
@ 2024-01-07 14:01 Thomas Weißschuh
2024-01-07 14:01 ` [PATCH v2 1/2] linux-user/elfload: test return value of getrlimit Thomas Weißschuh
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-07 14:01 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Thomas Weißschuh
Signed-off-by: Thomas Weißschuh <thomas@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 | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
base-commit: 0c1eccd368af8805ec0fb11e6cf25d0684d37328
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 v2 1/2] linux-user/elfload: test return value of getrlimit
2024-01-07 14:01 [PATCH v2 0/2] linux-user: two fixes to coredump generation Thomas Weißschuh
@ 2024-01-07 14:01 ` Thomas Weißschuh
2024-01-07 14:01 ` [PATCH v2 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
2024-01-09 21:33 ` [PATCH v2 0/2] linux-user: two fixes to coredump generation Richard Henderson
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-07 14:01 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 cf9e74468b11..74c9ecda1806 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.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump
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
2024-01-09 21:33 ` [PATCH v2 0/2] linux-user: two fixes to coredump generation Richard Henderson
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-07 14:01 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 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] linux-user: two fixes to coredump generation
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 ` [PATCH v2 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
@ 2024-01-09 21:33 ` Richard Henderson
2024-01-09 21:59 ` Thomas Weißschuh
2 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-01-09 21:33 UTC (permalink / raw)
To: Thomas Weißschuh, Laurent Vivier; +Cc: qemu-devel
On 1/8/24 01:01, Thomas Weißschuh wrote:
> Signed-off-by: Thomas Weißschuh <thomas@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 | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> ---
> base-commit: 0c1eccd368af8805ec0fb11e6cf25d0684d37328
> change-id: 20231115-qemu-user-dumpable-d499c0396103
>
> Best regards,
Both patches look good for correctness, but both have style issues: need braces on those
if statements.
With that fixed,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH v2 0/2] linux-user: two fixes to coredump generation
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
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2024-01-09 21:59 UTC (permalink / raw)
To: Richard Henderson; +Cc: Laurent Vivier, qemu-devel
On 2024-01-10 08:33:11+1100, Richard Henderson wrote:
> On 1/8/24 01:01, Thomas Weißschuh wrote:
> > Signed-off-by: Thomas Weißschuh <thomas@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 | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> > ---
> > base-commit: 0c1eccd368af8805ec0fb11e6cf25d0684d37328
> > change-id: 20231115-qemu-user-dumpable-d499c0396103
> >
> > Best regards,
>
> Both patches look good for correctness, but both have style issues: need
> braces on those if statements.
>
> With that fixed,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Thanks,
I added the braces for the next revision, which I'll send after waiting
some more feedback.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-09 22:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Thomas Weißschuh
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
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).