]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fuse: call pipe_buf_release() under pipe lock
authorJann Horn <jannh@google.com>
Sat, 12 Jan 2019 01:39:05 +0000 (02:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Feb 2019 09:09:05 +0000 (10:09 +0100)
commit 9509941e9c534920ccc4771ae70bd6cbbe79df1c upstream.

Some of the pipe_buf_release() handlers seem to assume that the pipe is
locked - in particular, anon_pipe_buf_release() accesses pipe->tmp_page
without taking any extra locks. From a glance through the callers of
pipe_buf_release(), it looks like FUSE is the only one that calls
pipe_buf_release() without having the pipe locked.

This bug should only lead to a memory leak, nothing terrible.

Fixes: dd3bb14f44a6 ("fuse: support splice() writing to fuse device")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fuse/dev.c

index 0560de4732fd18e54a03cbdd8418183afaf37c5e..98580726635c06e28278f8311f9377c4a3845a02 100644 (file)
@@ -1971,10 +1971,13 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
 
        ret = fuse_dev_do_write(fc, &cs, len);
 
+       pipe_lock(pipe);
        for (idx = 0; idx < nbuf; idx++) {
                struct pipe_buffer *buf = &bufs[idx];
                buf->ops->release(pipe, buf);
        }
+       pipe_unlock(pipe);
+
 out:
        kfree(bufs);
        return ret;