diff mbox series

[01/14] linux-user/elfload: Disable core dump if getrlimit fails

Message ID 20240227184833.193836-2-richard.henderson@linaro.org
State Superseded
Headers show
Series linux-user: Rewrite core dump | expand

Commit Message

Richard Henderson Feb. 27, 2024, 6:48 p.m. UTC
Do not dump core at all if getrlimit fails; this ensures
that dumpsize is valid throughout the function, not just
for the initial test vs rlim_cur.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Bennée Feb. 27, 2024, 7:40 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> Do not dump core at all if getrlimit fails; this ensures
> that dumpsize is valid throughout the function, not just
> for the initial test vs rlim_cur.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
diff mbox series

Patch

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index b8eef893d0..fb47fe39c9 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4673,7 +4673,7 @@  static int elf_core_dump(int signr, const CPUArchState *env)
         return 0;
     }
 
-    if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) {
+    if (getrlimit(RLIMIT_CORE, &dumpsize) < 0 || dumpsize.rlim_cur == 0) {
         return 0;
     }