From: Andrew Morton <akpm@linux-foundation.org>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: linux-kernel@vger.kernel.org, earl_chew@agilent.com,
oleg@redhat.com, alan@lxorguk.ukuu.org.uk, andi@firstfloor.org
Subject: Re: [PATCH 1/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern: recursive dump detection
Date: Fri, 26 Jun 2009 12:37:23 -0700 [thread overview]
Message-ID: <20090626123723.9b6f88c2.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090626180222.GD7337@hmsreliant.think-freely.org>
On Fri, 26 Jun 2009 14:02:22 -0400
Neil Horman <nhorman@tuxdriver.com> wrote:
>
> core_pattern: Change how we detect recursive dumps with core_pattern pipes
>
> Change how we detect recursive dumps. Currently we have a mechanism by which
> we try to compare pathnames of the crashing process to the core_pattern path.
> This is broken for a dozen reasons, and just doesn't work in any sort of robust
> way. I'm replacing it with the use of a 0 RLIMIT_CORE value. Since helper
> apps set RLIMIT_CORE to zero, we don't write out core files for any process with
> that particular limit set. It the core_pattern is a pipe, any non-zero limit is
> translated to RLIM_INFINITY. This allows complete dumps to be captured, but
> prevents infinite recursion in the event that the core_pattern process itself
> crashes.
>
The patch appears to be against 2.6.30 or something. I get rejects due
to some other patch in exec.c which was added three weeks ago. Please
don't do that :(
>
>
> exec.c | 32 +++++++++++++++++++-------------
> 1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index ebe359f..163cfa7 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1802,22 +1802,28 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
> goto fail_unlock;
>
> if (ispipe) {
> - helper_argv = argv_split(GFP_KERNEL, corename+1, &helper_argc);
> - /* Terminate the string before the first option */
> - delimit = strchr(corename, ' ');
> - if (delimit)
> - *delimit = '\0';
> - delimit = strrchr(helper_argv[0], '/');
> - if (delimit)
> - delimit++;
> - else
> - delimit = helper_argv[0];
> - if (!strcmp(delimit, current->comm)) {
> - printk(KERN_NOTICE "Recursive core dump detected, "
> - "aborting\n");
> + if (core_limit == 0) {
> + /*
> + * Normally core limits are irrelevant to pipes, since
> + * we're not writing to the file system, but we use
> + * core_limit of 0 here as a speacial value. Any
> + * non-zero limit gets set to RLIM_INFINITY below, but
> + * a limit of 0 skips the dump. This is a consistent
> + * way to catch recursive crashes. We can still crash
> + * if the core_pattern binary sets RLIM_CORE = !0
> + * but it runs as root, and can do lots of stupid things
> + * Note that we use task_tgid_vnr here to grab the pid of the
> + * process group leader. That way we get the right pid if a thread
> + * in a multi-threaded core_pattern process dies.
> + */
> + printk(KERN_WARNING "Process %d(%s) has RLIMIT_CORE set to 0\n",
> + task_tgid_vnr(current), current->comm);
> + printk(KERN_WARNING "Aborting core\n");
> goto fail_unlock;
> }
A few cosmetic things:
- The asterisks don't line up in the comment block. Normally we'll do
/*
*
*
rather than
/*
*
*
- The comment overflows 80 columns and makes a mess.
- Would it not be neater to do this check in a separate function?
Then the comment block can go above the function rather than being
all scrunched to the right and do_coredump() (which is already >150
lines) just gets
if (ispipe) {
+ if (core_limit_is_zero())
+ goto fail_unlock;
next prev parent reply other threads:[~2009-06-26 19:38 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-22 17:28 [PATCH] exec: Make do_coredump more robust and safer when using pipes in core_pattern Neil Horman
2009-06-25 23:30 ` Andrew Morton
2009-06-26 1:49 ` Neil Horman
2009-06-26 10:48 ` Neil Horman
2009-06-26 16:20 ` Andrew Morton
2009-06-26 17:30 ` Neil Horman
2009-06-28 19:31 ` Andi Kleen
2009-06-28 20:52 ` Andrew Morton
2009-06-28 21:00 ` Andi Kleen
2009-06-28 21:18 ` Andrew Morton
2009-06-28 21:50 ` Eric W. Biederman
2009-06-28 21:35 ` Eric W. Biederman
2009-06-28 21:48 ` Andi Kleen
2009-06-28 22:06 ` Eric W. Biederman
2009-06-29 9:15 ` Andi Kleen
2009-06-28 21:52 ` Andrew Morton
2009-06-26 18:00 ` Neil Horman
2009-06-26 18:02 ` [PATCH 1/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern: recursive dump detection Neil Horman
2009-06-26 16:59 ` Oleg Nesterov
2009-06-26 20:24 ` Neil Horman
2009-06-26 19:14 ` [PATCH 0/2] do_coredump: misc cleanups Oleg Nesterov
2009-06-26 19:14 ` [PATCH 1/2] do_coredump: factor out put_cred() calls Oleg Nesterov
2009-06-26 22:40 ` Roland McGrath
2009-06-26 20:33 ` Oleg Nesterov
2009-06-26 19:16 ` [PATCH 2/2] do_coredump: move !ispipe code into "else" branch Oleg Nesterov
2009-06-26 20:18 ` Q: do_coredump() && d_unhashed() Oleg Nesterov
2009-06-26 22:57 ` [PATCH 0/2] do_coredump: misc cleanups Neil Horman
2009-06-26 19:37 ` Andrew Morton [this message]
2009-06-26 20:17 ` [PATCH 1/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern: recursive dump detection Neil Horman
2009-06-26 18:03 ` [PATCH 2/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern: wait for core collectors Neil Horman
2009-06-26 16:48 ` Oleg Nesterov
2009-06-26 20:20 ` Neil Horman
2009-06-29 0:33 ` [PATCH 1/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v3) Neil Horman
2009-06-29 0:35 ` [PATCH 2/2] " Neil Horman
2009-06-28 22:24 ` Oleg Nesterov
2009-06-28 23:24 ` Oleg Nesterov
2009-06-29 2:36 ` Neil Horman
2009-06-28 23:32 ` Oleg Nesterov
2009-06-29 10:21 ` Neil Horman
2009-06-30 0:06 ` Oleg Nesterov
2009-06-29 0:32 ` [PATCH 0/2] " Neil Horman
2009-06-30 17:38 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v4) Neil Horman
2009-06-30 17:42 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v4) Neil Horman
2009-06-30 17:43 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v4) Neil Horman
2009-06-30 17:46 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v4) Neil Horman
2009-07-01 5:52 ` Oleg Nesterov
2009-07-01 10:31 ` Neil Horman
2009-07-01 12:25 ` Oleg Nesterov
2009-07-01 14:12 ` Neil Horman
2009-07-01 14:48 ` Oleg Nesterov
2009-07-01 15:26 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v5) Neil Horman
2009-07-01 15:30 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v5) Neil Horman
2009-07-01 15:34 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v5) Neil Horman
2009-07-01 15:37 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v5) Neil Horman
2009-07-01 16:06 ` Oleg Nesterov
2009-07-01 18:19 ` Neil Horman
2009-07-01 18:28 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v6) Neil Horman
2009-07-01 18:31 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v6) Neil Horman
2009-07-01 18:32 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v6) Neil Horman
2009-07-01 18:37 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v6) Neil Horman
2009-07-02 8:29 ` Oleg Nesterov
2009-07-02 10:29 ` Neil Horman
2009-07-02 11:36 ` Oleg Nesterov
2009-07-02 14:44 ` Neil Horman
2009-07-02 15:37 ` Oleg Nesterov
2009-07-02 17:53 ` Neil Horman
2009-07-03 10:10 ` Oleg Nesterov
2009-07-02 22:57 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v7) Neil Horman
2009-07-02 22:59 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v7) Neil Horman
2009-07-02 23:00 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v7) Neil Horman
2009-07-02 23:01 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v7) Neil Horman
2009-07-03 10:16 ` Oleg Nesterov
2009-07-03 10:44 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v8) Neil Horman
2009-07-03 10:50 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v8) Neil Horman
2009-07-07 16:14 ` Neil Horman
2009-07-03 10:51 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v8) Neil Horman
2009-07-07 16:15 ` Neil Horman
2009-07-03 10:52 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v8) Neil Horman
2009-07-07 16:19 ` Neil Horman
2009-07-07 16:35 ` Oleg Nesterov
2009-07-07 16:13 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v8) Neil Horman
2009-07-20 15:49 ` [PATCH 0/3] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v9) Neil Horman
2009-07-20 16:27 ` [PATCH 1/3] exec: Make do_coredump more resilient to recursive crashes (v9) Neil Horman
2009-07-20 16:29 ` [PATCH 2/3] exec: let do_coredump limit the number of concurrent dumps to pipes (v9) Neil Horman
2009-08-07 17:08 ` Randy Dunlap
2009-07-20 16:32 ` [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v9) Neil Horman
2009-07-29 15:13 ` [PATCH] exec: Make do_coredump more robust and safer when using pipes in core_pattern Scott James Remnant
2009-07-29 20:18 ` Neil Horman
2009-07-31 20:20 ` Scott James Remnant
2009-08-01 13:41 ` Neil Horman
2009-08-01 18:28 ` Scott James Remnant
2009-08-02 0:22 ` Neil Horman
2009-08-02 13:49 ` Scott James Remnant
2009-08-02 23:50 ` Neil Horman
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=20090626123723.9b6f88c2.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=andi@firstfloor.org \
--cc=earl_chew@agilent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=oleg@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.