From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Roman Kisel <romank@linux.microsoft.com>
Cc: akpm@linux-foundation.org, apais@linux.microsoft.com,
ardb@kernel.org, brauner@kernel.org, ebiederm@xmission.com,
jack@suse.cz, keescook@chromium.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, nagvijay@microsoft.com, oleg@redhat.com,
tandersen@netflix.com, vincent.whitchurch@axis.com,
viro@zeniv.linux.org.uk, apais@microsoft.com,
ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev
Subject: Re: [PATCH 1/1] binfmt_elf, coredump: Log the reason of the failed core dumps
Date: Tue, 18 Jun 2024 08:18:49 +0200 [thread overview]
Message-ID: <20240618061849.Vh9N3ds2@linutronix.de> (raw)
In-Reply-To: <20240617234133.1167523-2-romank@linux.microsoft.com>
On 2024-06-17 16:41:30 [-0700], Roman Kisel wrote:
> Missing, failed, or corrupted core dumps might impede crash
> investigations. To improve reliability of that process and consequently
> the programs themselves, one needs to trace the path from producing
> a core dumpfile to analyzing it. That path starts from the core dump file
> written to the disk by the kernel or to the standard input of a user
> mode helper program to which the kernel streams the coredump contents.
> There are cases where the kernel will interrupt writing the core out or
> produce a truncated/not-well-formed core dump.
How much of this happened and how much of this is just "let me handle
everything that could go wrong".
The cases where it was interrupted without a hint probably deserve a
note rather then leaving a half of coredump back.
> Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index a57a06b80f57..a7200c9024c6 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -777,9 +807,18 @@ void do_coredump(const kernel_siginfo_t *siginfo)
> }
> file_end_write(cprm.file);
> free_vma_snapshot(&cprm);
> + } else {
> + pr_err("Core dump to |%s has been interrupted\n", cn.corename);
> + retval = -EAGAIN;
> + goto fail;
> }
> + pr_info("Core dump to |%s: vma_count %d, vma_data_size %lu, written %lld bytes, pos %lld\n",
> + cn.corename, cprm.vma_count, cprm.vma_data_size, cprm.written, cprm.pos);
Probably too noisy in the default case. The offsets probably don't
matter unless you debug.
> if (ispipe && core_pipe_limit)
> wait_for_dump_helpers(cprm.file);
> +
> + retval = 0;
> +
> close_fail:
> if (cprm.file)
> filp_close(cprm.file, NULL);
> diff --git a/include/linux/coredump.h b/include/linux/coredump.h
> index 0904ba010341..8b29be758a87 100644
> --- a/include/linux/coredump.h
> +++ b/include/linux/coredump.h
> @@ -42,9 +42,9 @@ extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
> extern int dump_align(struct coredump_params *cprm, int align);
> int dump_user_range(struct coredump_params *cprm, unsigned long start,
> unsigned long len);
> -extern void do_coredump(const kernel_siginfo_t *siginfo);
> +extern int do_coredump(const kernel_siginfo_t *siginfo);
> #else
> -static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
> +static inline int do_coredump(const kernel_siginfo_t *siginfo) {}
This probably does not compile.
> #endif
>
> #if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 1f9dd41c04be..f2ecf29a994d 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2675,6 +2675,7 @@ bool get_signal(struct ksignal *ksig)
> struct sighand_struct *sighand = current->sighand;
> struct signal_struct *signal = current->signal;
> int signr;
> + int ret;
>
> clear_notify_signal();
> if (unlikely(task_work_pending(current)))
> @@ -2891,7 +2892,9 @@ bool get_signal(struct ksignal *ksig)
> * first and our do_group_exit call below will use
> * that value and ignore the one we pass it.
> */
> - do_coredump(&ksig->info);
> + ret = do_coredump(&ksig->info);
> + if (ret)
> + pr_err("coredump has not been created, error %d\n", ret);
So you preserve the error code just for one additional note.
> }
>
> /*
Sebastian
next prev parent reply other threads:[~2024-06-18 6:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 23:41 [PATCH 0/1] " Roman Kisel
2024-06-17 23:41 ` [PATCH 1/1] " Roman Kisel
2024-06-17 23:52 ` Kees Cook
2024-06-18 15:49 ` Roman Kisel
2024-06-18 6:18 ` Sebastian Andrzej Siewior [this message]
2024-06-18 16:30 ` Roman Kisel
2024-06-18 21:21 ` Eric W. Biederman
2024-06-20 19:10 ` Roman Kisel
2024-06-18 10:54 ` kernel test robot
2024-06-18 11:31 ` kernel test robot
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=20240618061849.Vh9N3ds2@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=apais@linux.microsoft.com \
--cc=apais@microsoft.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nagvijay@microsoft.com \
--cc=oleg@redhat.com \
--cc=romank@linux.microsoft.com \
--cc=ssengar@microsoft.com \
--cc=sunilmut@microsoft.com \
--cc=tandersen@netflix.com \
--cc=vdso@hexbites.dev \
--cc=vincent.whitchurch@axis.com \
--cc=viro@zeniv.linux.org.uk \
/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