diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-21 10:59:34 -0800 |
---|---|---|
committer | Nolen Johnson <johnsonnolen@gmail.com> | 2024-07-22 13:55:01 -0400 |
commit | ee52f095392a348760021475518edb19d08eac14 (patch) | |
tree | c0bd03e82d717e987994aa2b694d14cbe7b644d2 | |
parent | 6c9ab53cd4f1f751523f75189bd118d2b30dfc4c (diff) |
splice: reinstate SIGPIPE/EPIPE handling
commit 52bce91165e5f2db422b2b972e83d389e5e4725c upstream.
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>
Change-Id: I585c8fde68ba0ee61a8c7687eca80fc848cefc96
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 9df28d5069c4..0562b990d64e 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1303,7 +1303,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)) @@ -1312,7 +1318,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, |