From 79efa8e7ab4282c8c5e3a917531d5c42452377a5 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Tue, 31 Jan 2017 19:04:20 +0300 Subject: [PATCH] coredump: really extract container cmdline (#5167) Fixes: ``` root# systemd-nspawn -D ./cont/ --register=no /bin/sh -c '/bin/sh -c "kill -ABRT \$\$"' ... Container cont failed with error code 134. root# journalctl MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 -o verbose | grep -i container_cmdline ...prints nothing... ...should be COREDUMP_CONTAINER_CMDLINE=systemd-nspawn -D ./cont/ --register=no /bin/sh -c /bin/sh -c "kill -ABRT \$\$" ``` Also, fixes CID #1368263 ``` ==352== 130 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==352== at 0x4C2ED5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==352== by 0x4ED8581: greedy_realloc (alloc-util.c:57) ==352== by 0x4ECAAD5: get_process_cmdline (process-util.c:147) ==352== by 0x10E385: get_process_container_parent_cmdline (coredump.c:645) ==352== by 0x112949: process_kernel (coredump.c:1240) ==352== by 0x113003: main (coredump.c:1297) ==352== ``` (cherry picked from commit d3cba4eaf618ced1935a96e721b2fbcbad7694bb) --- src/coredump/coredump.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 6bd0e925eb..1c5e72c835 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -642,7 +642,11 @@ static int get_process_container_parent_cmdline(pid_t pid, char** cmdline) { if (r < 0) return r; - return get_process_cmdline(container_pid, 0, false, cmdline); + r = get_process_cmdline(container_pid, 0, false, cmdline); + if (r < 0) + return r; + + return 1; } static int change_uid_gid(const char *context[]) {