splice: fix racy pipe->buffers uses
authorEric Dumazet <edumazet@google.com>
Tue, 12 Jun 2012 13:24:40 +0000 (15:24 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 12 Jul 2012 03:31:59 +0000 (04:31 +0100)
commit9558b2ab1db5e94fcb7d5ab111a32e423a016c09
tree9dbabf74f3c971e5575e75ffab5bdc926021391f
parent1990855918045c6bd2c8b7ad62917d141eed4332
splice: fix racy pipe->buffers uses

commit 047fe3605235888f3ebcda0c728cb31937eadfe6 upstream.

Dave Jones reported a kernel BUG at mm/slub.c:3474! triggered
by splice_shrink_spd() called from vmsplice_to_pipe()

commit 35f3d14dbbc5 (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>
Tested-by: Dave Jones <davej@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[bwh: Backported to 3.2:
 - Adjust context in vmsplice_to_pipe()
 - Update one more call to splice_shrink_spd(), from skb_splice_bits()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/splice.c
include/linux/splice.h
kernel/relay.c
kernel/trace/trace.c
mm/shmem.c
net/core/skbuff.c