Re: [PATCH 3/3] exec: Allow do_coredump to wait for user space pipe readers to complete (v7)

Oleg Nesterov
2009-07-03T10:19:16Z

On 07/02, Neil Horman wrote:
>
> +static void wait_for_dump_helpers(struct file *file)
> +{
> + struct pipe_inode_info *pipe;
> +
> + pipe = file->f_path.dentry->d_inode->i_pipe;
> +
> + pipe_lock(pipe);
> + pipe->readers++;
> + pipe->writers--;
> +
> + while ((pipe->readers > 1) && (!fatal_signal_pending(current))) {
> + wake_up_interruptible_sync(&pipe->wait);
> + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
> + pipe_wait(pipe);
> + }

The kernel can hang on UP machine.

Suppose that rt task starts the coredump and then recieves a non-fatal
signal before core_pattern app closes stdin.

In that case this "while()" above becomes a busy-wait loop which never
stops.

Neil, please use signal_pending() as I said. Yes, this means wait_for_
will abort if we recieve a non-fatal signal. But as I said we have other
problems with signals here, when we fix them wait_for_dump_helpers()
will be fixed automatically.

Oleg.