]> git.baikalelectronics.ru Git - kernel.git/commit
fix short copy handling in copy_mc_pipe_to_iter()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jun 2022 23:50:29 +0000 (19:50 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:22:51 +0000 (14:22 +0200)
commitd5f616e80f514ba44e84c02de66ad655cd6515f9
treeda325de08e8df3c0fd7689a51702de622cb056aa
parent091ed924c730f42984b27dee2b11758c04f59b0e
fix short copy handling in copy_mc_pipe_to_iter()

commit 2fe5384b305661875508491b4bc9b0178cde91ce upstream.

Unlike other copying operations on ITER_PIPE, copy_mc_to_iter() can
result in a short copy.  In that case we need to trim the unused
buffers, as well as the length of partially filled one - it's not
enough to set ->head, ->iov_offset and ->count to reflect how
much had we copied.  Not hard to fix, fortunately...

I'd put a helper (pipe_discard_from(pipe, head)) into pipe_fs_i.h,
rather than iov_iter.c - it has nothing to do with iov_iter and
having it will allow us to avoid an ugly kludge in fs/splice.c.
We could put it into lib/iov_iter.c for now and move it later,
but I don't see the point going that way...

Cc: stable@kernel.org # 4.19+
Fixes: b796fdde4bdf "lib/iov_iter: Fix pipe handling in _copy_to_iter_mcsafe()"
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/pipe_fs_i.h
lib/iov_iter.c