Skip to content

Commit 7073851

Browse files
torvaldsPixelBoot
authored andcommitted
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>
1 parent 3207cd8 commit 7073851

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

fs/splice.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,13 @@ EXPORT_SYMBOL(do_splice_direct);
13031303

13041304
static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags)
13051305
{
1306-
while (pipe->nrbufs == pipe->buffers) {
1306+
for (;;) {
1307+
if (unlikely(!pipe->readers)) {
1308+
send_sig(SIGPIPE, current, 0);
1309+
return -EPIPE;
1310+
}
1311+
if (pipe->nrbufs != pipe->buffers)
1312+
return 0;
13071313
if (flags & SPLICE_F_NONBLOCK)
13081314
return -EAGAIN;
13091315
if (signal_pending(current))
@@ -1312,7 +1318,6 @@ static int wait_for_space(struct pipe_inode_info *pipe, unsigned flags)
13121318
pipe_wait(pipe);
13131319
pipe->waiting_writers--;
13141320
}
1315-
return 0;
13161321
}
13171322

13181323
static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,

0 commit comments

Comments
 (0)