aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-04-11 12:01:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-04-12 07:04:19 -0400
commita786c06d9f2719203c00b3d97b21f9a96980d0b5 (patch)
tree29a5e2ea710084cc115ec496e667658704ab72c2
parent19dfc1f5f2ef03a52aa30c8257c5745edef23f55 (diff)
missing bits of "splice: fix racy pipe->buffers uses"
that commit has fixed only the parts of that mess in fs/splice.c itself; there had been more in several other ->splice_read() instances... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--kernel/relay.c2
-rw-r--r--kernel/trace/trace.c4
-rw-r--r--mm/shmem.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 98833f664fb6..7d38607649a3 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1251,7 +1251,7 @@ static ssize_t subbuf_splice_actor(struct file *in,
1251 subbuf_pages = rbuf->chan->alloc_size >> PAGE_SHIFT; 1251 subbuf_pages = rbuf->chan->alloc_size >> PAGE_SHIFT;
1252 pidx = (read_start / PAGE_SIZE) % subbuf_pages; 1252 pidx = (read_start / PAGE_SIZE) % subbuf_pages;
1253 poff = read_start & ~PAGE_MASK; 1253 poff = read_start & ~PAGE_MASK;
1254 nr_pages = min_t(unsigned int, subbuf_pages, pipe->buffers); 1254 nr_pages = min_t(unsigned int, subbuf_pages, spd.nr_pages_max);
1255 1255
1256 for (total_len = 0; spd.nr_pages < nr_pages; spd.nr_pages++) { 1256 for (total_len = 0; spd.nr_pages < nr_pages; spd.nr_pages++) {
1257 unsigned int this_len, this_end, private; 1257 unsigned int this_len, this_end, private;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7511de35257f..27924caaa124 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4410,7 +4410,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
4410 trace_access_lock(iter->cpu_file); 4410 trace_access_lock(iter->cpu_file);
4411 4411
4412 /* Fill as many pages as possible. */ 4412 /* Fill as many pages as possible. */
4413 for (i = 0, rem = len; i < pipe->buffers && rem; i++) { 4413 for (i = 0, rem = len; i < spd.nr_pages_max && rem; i++) {
4414 spd.pages[i] = alloc_page(GFP_KERNEL); 4414 spd.pages[i] = alloc_page(GFP_KERNEL);
4415 if (!spd.pages[i]) 4415 if (!spd.pages[i])
4416 break; 4416 break;
@@ -5267,7 +5267,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5267 trace_access_lock(iter->cpu_file); 5267 trace_access_lock(iter->cpu_file);
5268 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); 5268 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
5269 5269
5270 for (i = 0; i < pipe->buffers && len && entries; i++, len -= PAGE_SIZE) { 5270 for (i = 0; i < spd.nr_pages_max && len && entries; i++, len -= PAGE_SIZE) {
5271 struct page *page; 5271 struct page *page;
5272 int r; 5272 int r;
5273 5273
diff --git a/mm/shmem.c b/mm/shmem.c
index 17d3799d04bd..37400a148f29 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1613,7 +1613,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
1613 index = *ppos >> PAGE_CACHE_SHIFT; 1613 index = *ppos >> PAGE_CACHE_SHIFT;
1614 loff = *ppos & ~PAGE_CACHE_MASK; 1614 loff = *ppos & ~PAGE_CACHE_MASK;
1615 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 1615 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
1616 nr_pages = min(req_pages, pipe->buffers); 1616 nr_pages = min(req_pages, spd.nr_pages_max);
1617 1617
1618 spd.nr_pages = find_get_pages_contig(mapping, index, 1618 spd.nr_pages = find_get_pages_contig(mapping, index,
1619 nr_pages, spd.pages); 1619 nr_pages, spd.pages);