summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2019-04-04 23:59:25 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-02 10:02:44 +0200
commit8659a04c77e2ca52ce2af42f7c50b49e690ffb19 (patch)
tree6df98f2c87e555dc5f0d75f0ed8b40b97517161f /fs
parent68ab802fb8ccc6cbd953aa631bba7d98bc491996 (diff)
downloadlinux-8659a04c77e2ca52ce2af42f7c50b49e690ffb19.tar.gz
linux-8659a04c77e2ca52ce2af42f7c50b49e690ffb19.tar.bz2
linux-8659a04c77e2ca52ce2af42f7c50b49e690ffb19.zip
tracing: Fix buffer_ref pipe ops
commit b987222654f84f7b4ca95b3a55eca784cb30235b upstream. This fixes multiple issues in buffer_pipe_buf_ops: - The ->steal() handler must not return zero unless the pipe buffer has the only reference to the page. But generic_pipe_buf_steal() assumes that every reference to the pipe is tracked by the page's refcount, which isn't true for these buffers - buffer_pipe_buf_get(), which duplicates a buffer, doesn't touch the page's refcount. Fix it by using generic_pipe_buf_nosteal(), which refuses every attempted theft. It should be easy to actually support ->steal, but the only current users of pipe_buf_steal() are the virtio console and FUSE, and they also only use it as an optimization. So it's probably not worth the effort. - The ->get() and ->release() handlers can be invoked concurrently on pipe buffers backed by the same struct buffer_ref. Make them safe against concurrency by using refcount_t. - The pointers stored in ->private were only zeroed out when the last reference to the buffer_ref was dropped. As far as I know, this shouldn't be necessary anyway, but if we do it, let's always do it. Link: http://lkml.kernel.org/r/20190404215925.253531-1-jannh@google.com Cc: Ingo Molnar <mingo@redhat.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: stable@vger.kernel.org Fixes: 73a757e63114d ("ring-buffer: Return reader page back into existing ring buffer") Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/splice.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 90c29675d573..7da7d5437472 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -333,8 +333,8 @@ const struct pipe_buf_operations default_pipe_buf_ops = {
.get = generic_pipe_buf_get,
};
-static int generic_pipe_buf_nosteal(struct pipe_inode_info *pipe,
- struct pipe_buffer *buf)
+int generic_pipe_buf_nosteal(struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
{
return 1;
}