<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/splice.c, branch linux-3.18.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.18.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.18.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-11-10T15:39:20Z</updated>
<entry>
<title>vfs: Make sendfile(2) killable even better</title>
<updated>2018-11-10T15:39:20Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2015-11-23T12:09:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ce2c2e07337e98eb42904ef27c3ce62972d22a60'/>
<id>urn:sha1:ce2c2e07337e98eb42904ef27c3ce62972d22a60</id>
<content type='text'>
[ Upstream commit c725bfce7968009756ed2836a8cd7ba4dc163011 ]

Commit 296291cdd162 (mm: make sendfile(2) killable) fixed an issue where
sendfile(2) was doing a lot of tiny writes into a filesystem and thus
was unkillable for a long time. However sendfile(2) can be (mis)used to
issue lots of writes into arbitrary file descriptor such as evenfd or
similar special file descriptors which never hit the standard filesystem
write path and thus are still unkillable. E.g. the following example
from Dmitry burns CPU for ~16s on my test system without possibility to
be killed:

        int r1 = eventfd(0, 0);
        int r2 = memfd_create("", 0);
        unsigned long n = 1&lt;&lt;30;
        fallocate(r2, 0, 0, n);
        sendfile(r1, r2, 0, n);

There are actually quite a few tests for pending signals in sendfile
code however we data to write is always available none of them seems to
trigger. So fix the problem by adding a test for pending signal into
splice_from_pipe_next() also before the loop waiting for pipe buffers to
be available. This should fix all the lockup issues with sendfile of the
do-ton-of-tiny-writes nature.

CC: stable@vger.kernel.org
Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>splice: handle zero nr_pages in splice_to_pipe()</title>
<updated>2016-04-18T12:49:36Z</updated>
<author>
<name>Rabin Vincent</name>
</author>
<published>2016-03-10T20:19:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0651623b0d2d44343184791e7145f0fe871eec6e'/>
<id>urn:sha1:0651623b0d2d44343184791e7145f0fe871eec6e</id>
<content type='text'>
[ Upstream commit d6785d9152147596f60234157da2b02540c3e60f ]

Running the following command:

 busybox cat /sys/kernel/debug/tracing/trace_pipe &gt; /dev/null

with any tracing enabled pretty very quickly leads to various NULL
pointer dereferences and VM BUG_ON()s, such as these:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
 IP: [&lt;ffffffff8119df6c&gt;] generic_pipe_buf_release+0xc/0x40
 Call Trace:
  [&lt;ffffffff811c48a3&gt;] splice_direct_to_actor+0x143/0x1e0
  [&lt;ffffffff811c42e0&gt;] ? generic_pipe_buf_nosteal+0x10/0x10
  [&lt;ffffffff811c49cf&gt;] do_splice_direct+0x8f/0xb0
  [&lt;ffffffff81196869&gt;] do_sendfile+0x199/0x380
  [&lt;ffffffff81197600&gt;] SyS_sendfile64+0x90/0xa0
  [&lt;ffffffff8192cbee&gt;] entry_SYSCALL_64_fastpath+0x12/0x6d

 page dumped because: VM_BUG_ON_PAGE(atomic_read(&amp;page-&gt;_count) == 0)
 kernel BUG at include/linux/mm.h:367!
 invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
 RIP: [&lt;ffffffff8119df9c&gt;] generic_pipe_buf_release+0x3c/0x40
 Call Trace:
  [&lt;ffffffff811c48a3&gt;] splice_direct_to_actor+0x143/0x1e0
  [&lt;ffffffff811c42e0&gt;] ? generic_pipe_buf_nosteal+0x10/0x10
  [&lt;ffffffff811c49cf&gt;] do_splice_direct+0x8f/0xb0
  [&lt;ffffffff81196869&gt;] do_sendfile+0x199/0x380
  [&lt;ffffffff81197600&gt;] SyS_sendfile64+0x90/0xa0
  [&lt;ffffffff8192cd1e&gt;] tracesys_phase2+0x84/0x89

(busybox's cat uses sendfile(2), unlike the coreutils version)

This is because tracing_splice_read_pipe() can call splice_to_pipe()
with spd-&gt;nr_pages == 0.  spd_pages underflows in splice_to_pipe() and
we fill the page pointers and the other fields of the pipe_buffers with
garbage.

All other callers of splice_to_pipe() avoid calling it when nr_pages ==
0, and we could make tracing_splice_read_pipe() do that too, but it
seems reasonable to have splice_to_page() handle this condition
gracefully.

Cc: stable@vger.kernel.org
Signed-off-by: Rabin Vincent &lt;rabin@rab.in&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</content>
</entry>
<entry>
<title>vfs: export do_splice_direct() to modules</title>
<updated>2014-10-23T22:14:35Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2014-10-23T22:14:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1c118596a7682912106c80007102ce0184c77780'/>
<id>urn:sha1:1c118596a7682912106c80007102ce0184c77780</id>
<content type='text'>
Export do_splice_direct() to modules.  Needed by overlay filesystem.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
</content>
</entry>
<entry>
<title>Merge commit '9f12600fe425bc28f0ccba034a77783c09c15af4' into for-linus</title>
<updated>2014-06-12T04:28:09Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-06-12T04:27:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c1d5284c79fea050f115eadeec1dd1758e5c630'/>
<id>urn:sha1:9c1d5284c79fea050f115eadeec1dd1758e5c630</id>
<content type='text'>
Backmerge of dcache.c changes from mainline.  It's that, or complete
rebase...

Conflicts:
	fs/splice.c

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>kill generic_file_splice_write()</title>
<updated>2014-06-12T04:21:13Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-04-05T17:31:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5f073850602084fbcbb987948ff3e70ae273f7d2'/>
<id>urn:sha1:5f073850602084fbcbb987948ff3e70ae273f7d2</id>
<content type='text'>
no callers left

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>fs/splice.c: remove unneeded exports</title>
<updated>2014-06-12T04:21:11Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-04-05T08:35:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=96f9bc8fbc2440d90e15f02398e1de43f674b433'/>
<id>urn:sha1:96f9bc8fbc2440d90e15f02398e1de43f674b433</id>
<content type='text'>
ocfs2 was using a bunch of splice.c guts...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>-&gt;splice_write() via -&gt;write_iter()</title>
<updated>2014-06-12T04:18:51Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-04-05T08:27:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8d0207652cbe27d1f962050737848e5ad4671958'/>
<id>urn:sha1:8d0207652cbe27d1f962050737848e5ad4671958</id>
<content type='text'>
iter_file_splice_write() - a -&gt;splice_write() instance that gathers the
pipe buffers, builds a bio_vec-based iov_iter covering those and feeds
it to -&gt;write_iter().  A bunch of simple cases coverted to that...

[AV: fixed the braino spotted by Cyrill]

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>vfs: fix vmplice_to_user()</title>
<updated>2014-05-28T05:54:52Z</updated>
<author>
<name>Miklos Szeredi</name>
</author>
<published>2014-05-27T14:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b6dd6f4738837439c520e73995ec93fe1de2ec72'/>
<id>urn:sha1:b6dd6f4738837439c520e73995ec93fe1de2ec72</id>
<content type='text'>
Commit 6130f5315ee8 "switch vmsplice_to_user() to copy_page_to_iter()" in
v3.15-rc1 broke vmsplice(2).

This patch fixes two bugs:

 - count is not initialized to a proper value, which resulted in no data
   being copied

 - if rw_copy_check_uvector() returns negative then the iov might be leaked.

Tested OK.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>start adding the tag to iov_iter</title>
<updated>2014-05-06T21:32:49Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-03-06T00:28:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=71d8e532b1549a478e6a6a8a44f309d050294d00'/>
<id>urn:sha1:71d8e532b1549a478e6a6a8a44f309d050294d00</id>
<content type='text'>
For now, just use the same thing we pass to -&gt;direct_IO() - it's all
iovec-based at the moment.  Pass it explicitly to iov_iter_init() and
account for kvec vs. iovec in there, by the same kludge NFS -&gt;direct_IO()
uses.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>switch vmsplice_to_user() to copy_page_to_iter()</title>
<updated>2014-04-02T03:19:23Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2014-02-03T23:19:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6130f5315ee80a591285a25957af71621bd0f17e'/>
<id>urn:sha1:6130f5315ee80a591285a25957af71621bd0f17e</id>
<content type='text'>
I've switched the sanity checks on iovec to rw_copy_check_uvector();
we might need to do a local analog, if any behaviour differences are
not actually bugfixes here...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
</feed>
