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 1/2] linux-user/elfload: test return value of getrlimit
Date: Sun, 07 Jan 2024 15:01:53 +0100 [thread overview]
Message-ID: <20240107-qemu-user-dumpable-v2-1-54e3bcfc00c9@t-8ch.de> (raw)
In-Reply-To: <20240107-qemu-user-dumpable-v2-0-54e3bcfc00c9@t-8ch.de>
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
next prev 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 ` Thomas Weißschuh [this message]
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
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-1-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).