diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-21 19:59:34 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-21 19:59:34 +0100 |
commit | 52bce91165e5f2db422b2b972e83d389e5e4725c (patch) | |
tree | e4ca6d2e8d2e64b54a50fa3bf5995c676e2f7d49 /fs/splice.c | |
parent | Merge branch 'parisc-4.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git... (diff) | |
download | linux-52bce91165e5f2db422b2b972e83d389e5e4725c.tar.xz linux-52bce91165e5f2db422b2b972e83d389e5e4725c.zip |
splice: reinstate SIGPIPE/EPIPE handling
Commit 8924feff66f3 ("splice: lift pipe_lock out of splice_to_pipe()")
caused a regression when there were no more readers left on a pipe that
was being spliced into: rather than the expected SIGPIPE and -EPIPE
return value, the writer would end up waiting forever for space to free
up (which obviously was not going to happen with no readers around).
Fixes: 8924feff66f3 ("splice: lift pipe_lock out of splice_to_pipe()")
Reported-and-tested-by: Andreas Schwab <schwab@linux-m68k.org>
Debugged-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: stable@kernel.org # v4.9
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/splice.c')
-rw-r--r-- | fs/splice.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/splice.c b/fs/splice.c index 8ed7c9d8c0fb..873d83104e79 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1087,7 +1087,13 @@ EXPORT_SYMBOL(do_splice_direct); static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags) { - while (pipe->nrbufs == pipe->buffers) { + for (;;) { + if (unlikely(!pipe->readers)) { + send_sig(SIGPIPE, current, 0); + return -EPIPE; + } + if (pipe->nrbufs != pipe->buffers) + return 0; if (flags & SPLICE_F_NONBLOCK) return -EAGAIN; if (signal_pending(current)) @@ -1096,7 +1102,6 @@ static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags) pipe_wait(pipe); pipe->waiting_writers--; } - return 0; } static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe, |