1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-26 18:43:33 -05:00

iov_iter: Four fixes for ITER_XARRAY

Fix four things[1] in the patch that adds ITER_XARRAY[2]:

 (1) Remove the address_space struct predeclaration.  This is a holdover
     from when it was ITER_MAPPING.

 (2) Fix _copy_mc_to_iter() so that the xarray segment updates count and
     iov_offset in the iterator before returning.

 (3) Fix iov_iter_alignment() to not loop in the xarray case.  Because the
     middle pages are all whole pages, only the end pages need be
     considered - and this can be reduced to just looking at the start
     position in the xarray and the iteration size.

 (4) Fix iov_iter_advance() to limit the size of the advance to no more
     than the remaining iteration size.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Jeff Layton <jlayton@redhat.com>
Tested-by: Dave Wysochanski <dwysocha@redhat.com>
Link: https://lore.kernel.org/r/YIVrJT8GwLI0Wlgx@zeniv-ca.linux.org.uk [1]
Link: https://lore.kernel.org/r/161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk [2]
This commit is contained in:
David Howells 2021-04-25 22:02:38 +01:00
parent 26aaeffcaf
commit 3d14ec1fe6
2 changed files with 5 additions and 1 deletions

View file

@ -10,7 +10,6 @@
#include <uapi/linux/uio.h> #include <uapi/linux/uio.h>
struct page; struct page;
struct address_space;
struct pipe_inode_info; struct pipe_inode_info;
struct kvec { struct kvec {

View file

@ -791,6 +791,8 @@ size_t _copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
curr_addr = (unsigned long) from; curr_addr = (unsigned long) from;
bytes = curr_addr - s_addr - rem; bytes = curr_addr - s_addr - rem;
rcu_read_unlock(); rcu_read_unlock();
i->iov_offset += bytes;
i->count -= bytes;
return bytes; return bytes;
} }
}) })
@ -1147,6 +1149,7 @@ void iov_iter_advance(struct iov_iter *i, size_t size)
return; return;
} }
if (unlikely(iov_iter_is_xarray(i))) { if (unlikely(iov_iter_is_xarray(i))) {
size = min(size, i->count);
i->iov_offset += size; i->iov_offset += size;
i->count -= size; i->count -= size;
return; return;
@ -1346,6 +1349,8 @@ unsigned long iov_iter_alignment(const struct iov_iter *i)
return size | i->iov_offset; return size | i->iov_offset;
return size; return size;
} }
if (unlikely(iov_iter_is_xarray(i)))
return (i->xarray_start + i->iov_offset) | i->count;
iterate_all_kinds(i, size, v, iterate_all_kinds(i, size, v,
(res |= (unsigned long)v.iov_base | v.iov_len, 0), (res |= (unsigned long)v.iov_base | v.iov_len, 0),
res |= v.bv_offset | v.bv_len, res |= v.bv_offset | v.bv_len,