From: Oleg Nesterov <oleg@redhat.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, earl_chew@agilent.com,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Andi Kleen <andi@firstfloor.org>
Subject: Re: [PATCH 2/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern (v3)
Date: Tue, 30 Jun 2009 02:06:18 +0200 [thread overview]
Message-ID: <20090630000618.GA18342@redhat.com> (raw)
In-Reply-To: <20090629102152.GA7993@hmsreliant.think-freely.org>
On 06/29, Neil Horman wrote:
>
> On Mon, Jun 29, 2009 at 01:32:00AM +0200, Oleg Nesterov wrote:
> > On 06/28, Neil Horman wrote:
> > >
> > > On Mon, Jun 29, 2009 at 12:24:55AM +0200, Oleg Nesterov wrote:
> > > >
> > > > Perhaps this sysctl should be added in a separate patch? This patch mixes
> > > > differents things imho.
> > > >
> > > No, I disagree. If we're going to have a sysctl, It should be added in this
> > > patch. I agree that since these processes run as root, we can have all sort of
> > > bad things happen. But I think theres an advantage to being able to limit the
> > > damage that a core_pattern process can do if it never exits.
> >
> > Yes, but why it should be added in this patch?
> >
> I agree with what you said earlier, in that the sysctl is orthogonal to the
> wait_for_complete functionality, from an implementation standpoint. But I don't
> feel as though they are independent from a behavioral standpoint.
I think they are ;)
> Given that
> the sysctl defines a default value of zero in which unlimited parallel core
> dumps are allowed, but none are waited for, separating the patches creates a
> behavioral split in which the the core_pattern behavior changes for the span of
> one commit, and in such a way that the system can deadlock if the core_pattern
> process does bad things. To illustrate, say we applied the wait_for_core patch
> separately from sysctl patch. If someone built with both patches, their
> core_pattern behavior would appear unchanged, but if they built with only the
> first patch, and their core_pattern app had a bug in which the process never
> exited properly, they would get an unbounded backlog of unreaped processes.
Just send the sysctl first. If this limit makes sense (I think yes), then
it makes sense even without wait_for_core patch, because the buggy core_pattern
app can make problems even without wait_for_core.
This looks so obvious to me, but of course please do what you think right.
(from another message)
>
> So, I'd like to solicit your opinion on something here. I've run into an
> interesting chicken and egg problem in attempting to implement this. I found
> that while implementing this, that the user space component might be reliying on
> an feof condition on stdin to determine when to stop reading from the pipe.
I see.
> I see
> two options:
>
> 1) Require user space to parse the core file during its read, to know how much
> data to extract from the pipe, and call it a user space problem if they read
> more than that and wind up blocking indefinately?
I don't think we should break user-space.
> 2) Develop another way to detect that userspace is done and has exited.
Yes, as I said we can implement UMH_WAIT_CUSTOM_COMPLETION, but this needs
changes in kmod.c
> I personally like option 2, and I think I can do it using the inotify
Well, not good to depend on CONFIG_INOTIFY, and this looks like an overkill
to me.
How about (completely untested) patch below?
Oleg.
--- WAIT/fs/exec.c~CD_3_CLOSE_WAIT 2009-06-30 01:26:38.000000000 +0200
+++ WAIT/fs/exec.c 2009-06-30 01:47:18.000000000 +0200
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/fdtable.h>
+#include <linux/pipe_fs_i.h>
#include <linux/mm.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
@@ -1710,6 +1711,23 @@ int get_dumpable(struct mm_struct *mm)
return (ret >= 2) ? 2 : ret;
}
+static void xxx(struct file *file)
+{
+ struct pipe_inode_info *pipe = file->f_path.dentry->d_inode->i_pipe;
+
+ pipe_lock(pipe);
+ while (pipe->readers) {
+ pipe->readers++;
+ pipe->writers--;
+ wake_up_interruptible_sync(&pipe->wait);
+ kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
+ pipe_wait(pipe);
+ pipe->writers++;
+ pipe->readers--;
+ }
+ pipe_unlock(pipe);
+}
+
void do_coredump(long signr, int exit_code, struct pt_regs *regs)
{
struct core_state core_state;
@@ -1853,11 +1871,12 @@ void do_coredump(long signr, int exit_co
current->signal->group_exit_code |= 0x80;
close_fail:
+ if (ispipe)
+ xxx(file);
filp_close(file, NULL);
fail_unlock:
if (helper_argv)
argv_free(helper_argv);
-
coredump_finish(mm);
revert_creds(old_cred);
fail_creds:
next prev parent reply other threads:[~2009-06-30 0:09 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 ` [PATCH 1/2] exec: Make do_coredump more robust and safer when using pipes in core_pattern: recursive dump detection Andrew Morton
2009-06-26 20:17 ` 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 [this message]
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=20090630000618.GA18342@redhat.com \
--to=oleg@redhat.com \
--cc=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 \
/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