Skip to content

Commit c2489e0

Browse files
jankaraAl Viro
authored andcommitted
vfs: Avoid softlockups with sendfile(2)
The following test program from Dmitry can cause softlockups or RCU stalls as it copies 1GB from tmpfs into eventfd and we don't have any scheduling point at that path in sendfile(2) implementation: int r1 = eventfd(0, 0); int r2 = memfd_create("", 0); unsigned long n = 1<<30; fallocate(r2, 0, 0, n); sendfile(r1, r2, 0, n); Add cond_resched() into __splice_from_pipe() to fix the problem. CC: Dmitry Vyukov <dvyukov@google.com> CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c725bfc commit c2489e0

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/splice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd,
891891

892892
splice_from_pipe_begin(sd);
893893
do {
894+
cond_resched();
894895
ret = splice_from_pipe_next(pipe, sd);
895896
if (ret > 0)
896897
ret = splice_from_pipe_feed(pipe, sd, actor);

0 commit comments

Comments
 (0)