diff options
author | Sagi Grimberg <sagi@grimberg.me> | 2024-06-26 13:00:08 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-07-11 13:49:12 +0300 |
commit | 702b17f72de289a6509f11a04514ee2cc65a5879 (patch) | |
tree | 377d8b5805e4eb2354ebc011ceb4c7e3b6bf144c | |
parent | 895f5633a0369c07fb2151f54c55d59720841082 (diff) | |
download | linux-702b17f72de289a6509f11a04514ee2cc65a5879.tar.xz |
net: allow skb_datagram_iter to be called from any context
[ Upstream commit d2d30a376d9cc94c6fb730c58b3e5b7426ecb6de ]
We only use the mapping in a single context, so kmap_local is sufficient
and cheaper. Make sure to use skb_frag_foreach_page as skb frags may
contain compound pages and we need to map page by page.
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202406161539.b5ff7b20-oliver.sang@intel.com
Fixes: 950fcaecd5cc ("datagram: consolidate datagram copy to iter helpers")
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Link: https://patch.msgid.link/20240626100008.831849-1-sagi@grimberg.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | net/core/datagram.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/net/core/datagram.c b/net/core/datagram.c index 176eb5834746..e49aaf2d48b8 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -434,15 +434,22 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, end = start + skb_frag_size(frag); if ((copy = end - offset) > 0) { - struct page *page = skb_frag_page(frag); - u8 *vaddr = kmap(page); + u32 p_off, p_len, copied; + struct page *p; + u8 *vaddr; if (copy > len) copy = len; - n = INDIRECT_CALL_1(cb, simple_copy_to_iter, - vaddr + skb_frag_off(frag) + offset - start, - copy, data, to); - kunmap(page); + + skb_frag_foreach_page(frag, + skb_frag_off(frag) + offset - start, + copy, p, p_off, p_len, copied) { + vaddr = kmap_local_page(p); + n = INDIRECT_CALL_1(cb, simple_copy_to_iter, + vaddr + p_off, p_len, data, to); + kunmap_local(vaddr); + } + offset += n; if (n != copy) goto short_copy; |