From: Ben Chan <benc...@chromium.org> Make wait_for_dump_helpers() not abort piping the core dump data when the crashing process has received a non-fatal signal. The abort still occurs in the case of SIGKILL.
Addresses http://crosbug.com/21559 Changes since v1: * Mandeep Singh Baines * To prevent blocking suspend, add try_to_freeze(). Changes since v2: * LKML: <20130215150117.gb30...@redhat.com> Oleg Nestorov * Block non-fatal signals to avoid poll_wait busy waiting. * LKML: <20130215152538.9a61a44e.a...@linux-foundation.org> Andrew Morton * Added comment re: try_to_freeze and clarified commit message. Signed-off-by: Ben Chan <benc...@chromium.org> Signed-off-by: Mandeep Singh Baines <m...@chromium.org> CC: Oleg Nesterov <o...@redhat.com> CC: Tejun Heo <t...@kernel.org> CC: Andrew Morton <a...@linux-foundation.org> CC: Rafael J. Wysocki <r...@sisk.pl> CC: Ingo Molnar <mi...@redhat.com> --- fs/coredump.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/coredump.c b/fs/coredump.c index 1774932..976f6cc 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -32,6 +32,7 @@ #include <linux/pipe_fs_i.h> #include <linux/oom.h> #include <linux/compat.h> +#include <linux/freezer.h> #include <asm/uaccess.h> #include <asm/mmu_context.h> @@ -410,6 +411,11 @@ static void coredump_finish(struct mm_struct *mm) static void wait_for_dump_helpers(struct file *file) { struct pipe_inode_info *pipe; + sigset_t blocked, previous; + + /* Block all but fatal signals. */ + siginitsetinv(&blocked, sigmask(SIGKILL)); + sigprocmask(SIG_BLOCK, &blocked, &previous); pipe = file->f_path.dentry->d_inode->i_pipe; @@ -421,12 +427,22 @@ static void wait_for_dump_helpers(struct file *file) wake_up_interruptible_sync(&pipe->wait); kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); pipe_wait(pipe); + + /* + * Non-fatal signals are blocked. So we need to try + * to freeze in order to not block suspend. + */ + pipe_unlock(pipe); + try_to_freeze(); + pipe_lock(pipe); } pipe->readers--; pipe->writers++; pipe_unlock(pipe); + /* Restore signals. */ + sigprocmask(SIG_SETMASK, &previous, NULL); } /* -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/