mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
splice: fix racy pipe->buffers uses
Dave Jones reported a kernel BUG at mm/slub.c:3474! triggered
by splice_shrink_spd() called from vmsplice_to_pipe()
commit 35f3d14dbb (pipe: add support for shrinking and growing pipes)
added capability to adjust pipe->buffers.
Problem is some paths don't hold pipe mutex and assume pipe->buffers
doesn't change for their duration.
Fix this by adding nr_pages_max field in struct splice_pipe_desc, and
use it in place of pipe->buffers where appropriate.
splice_shrink_spd() loses its struct pipe_inode_info argument.
Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Tom Herbert <therbert@google.com>
Cc: stable <stable@vger.kernel.org> # 2.6.35
Tested-by: Dave Jones <davej@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -51,7 +51,8 @@ struct partial_page {
|
||||
struct splice_pipe_desc {
|
||||
struct page **pages; /* page map */
|
||||
struct partial_page *partial; /* pages[] may not be contig */
|
||||
int nr_pages; /* number of pages in map */
|
||||
int nr_pages; /* number of populated pages in map */
|
||||
unsigned int nr_pages_max; /* pages[] & partial[] arrays size */
|
||||
unsigned int flags; /* splice flags */
|
||||
const struct pipe_buf_operations *ops;/* ops associated with output pipe */
|
||||
void (*spd_release)(struct splice_pipe_desc *, unsigned int);
|
||||
@@ -85,9 +86,8 @@ extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *,
|
||||
/*
|
||||
* for dynamic pipe sizing
|
||||
*/
|
||||
extern int splice_grow_spd(struct pipe_inode_info *, struct splice_pipe_desc *);
|
||||
extern void splice_shrink_spd(struct pipe_inode_info *,
|
||||
struct splice_pipe_desc *);
|
||||
extern int splice_grow_spd(const struct pipe_inode_info *, struct splice_pipe_desc *);
|
||||
extern void splice_shrink_spd(struct splice_pipe_desc *);
|
||||
extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
|
||||
|
||||
extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
|
||||
|
||||
Reference in New Issue
Block a user