Commit 7ed3c624 authored by Jann Horn's avatar Jann Horn Committed by Stefan Bader

fuse: call pipe_buf_release() under pipe lock

BugLink: https://bugs.launchpad.net/bugs/1818813

commit 9509941e 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: dd3bb14f ("fuse: support splice() writing to fuse device")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 48075d7c
...@@ -2087,10 +2087,13 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, ...@@ -2087,10 +2087,13 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
ret = fuse_dev_do_write(fud, &cs, len); ret = fuse_dev_do_write(fud, &cs, len);
pipe_lock(pipe);
for (idx = 0; idx < nbuf; idx++) { for (idx = 0; idx < nbuf; idx++) {
struct pipe_buffer *buf = &bufs[idx]; struct pipe_buffer *buf = &bufs[idx];
buf->ops->release(pipe, buf); buf->ops->release(pipe, buf);
} }
pipe_unlock(pipe);
out: out:
kfree(bufs); kfree(bufs);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment