From: sashiko-bot@kernel.org
To: "Anton Leontev" <leontyevantony@gmail.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net v2] hv_netvsc: use kmap_local_page in netvsc_copy_to_send_buf
Date: Thu, 04 Jun 2026 16:39:00 +0000 [thread overview]
Message-ID: <20260604163900.A09211F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603163851.18058-1-leontyevantony@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The patch replaces `phys_to_virt()` with `kmap_local_page()` in `netvsc_copy_to_send_buf()` to support HIGHMEM SKB fragments. However, `kmap_local_page()` maps exactly one page (e.g., 4096 bytes). SKB fragments (such as those from TCP sends using `sk_page_frag()` or NFS) can be backed by compound pages where the fragment size (`len`) exceeds a single page, or where `offset + len` crosses a page boundary. The `pb` array populated by `init_page_array()` contains exactly one entry per fragment, meaning `pb[i].len` can exceed `PAGE_SIZE`. When `memcpy(dest, src + offset, len)` is called, it will read past the 4KB window mapped by `kmap_local_page()`. On 32-bit HIGHMEM systems, this accesses adjacent unmapped or unrelated fixmap slots, causing a fatal page fault or memory leakage.
--
commit dfe36312b193784583b28a894f895984d7d0ebba
Author: Anton Leontev <leontyevantony@gmail.com>
hv_netvsc: use kmap_local_page in netvsc_copy_to_send_buf
This patch replaces phys_to_virt() with kmap_local_page() to support HIGHMEM
SKB fragments that are beyond the LOWMEM boundary on 32-bit systems.
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 59e95341f9b1e..2038d9f5c9f9a 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
[ ... ]
> @@ -965,11 +966,14 @@ static void netvsc_copy_to_send_buf(struct netvsc_device *net_device,
> }
>
> for (i = 0; i < page_count; i++) {
> - char *src = phys_to_virt(pb[i].pfn << HV_HYP_PAGE_SHIFT);
> - u32 offset = pb[i].offset;
> + phys_addr_t paddr = pb[i].pfn << HV_HYP_PAGE_SHIFT;
> + struct page *page = phys_to_page(paddr);
> + u32 offset = offset_in_page(paddr) + pb[i].offset;
> u32 len = pb[i].len;
> + char *src = kmap_local_page(page);
>
> memcpy(dest, (src + offset), len);
[Severity: Critical]
Will this memcpy() read beyond the 1-page mapping established by
kmap_local_page()?
If the fragment size (len) plus offset exceeds PAGE_SIZE, it seems memcpy()
will read past the locally mapped window. SKB fragments can be backed by
compound pages where the fragment size exceeds a single page, and
init_page_array() assigns the full fragment size to pb[i].len:
drivers/net/hyperv/netvsc_drv.c:init_page_array() {
...
cur_pb->offset = offset_in_hvpage(offset);
cur_pb->len = skb_frag_size(frag);
cur_pb->pfn = pfn + (offset >> HV_HYP_PAGE_SHIFT);
...
}
Other parts of the subsystem also document that a pb entry can cross page
boundaries:
drivers/net/hyperv/netvsc.c:netvsc_build_mpb_array() {
...
/* Each entry in the input "pb" array must describe a contiguous range
* of guest physical memory so that the pfns are sequential if the range
* crosses a page boundary. */
...
for (j = 0; j < HVPFN_UP(offset + len); j++)
mpb_entry->pfnArray[j] = pb[i].pfn + j;
...
}
Could this regression cause a fatal page fault on 32-bit HIGHMEM guests when
an SKB fragment crosses a page boundary, or leak unrelated fixmap memory if
the adjacent slot happens to be mapped?
> + kunmap_local(src);
> dest += len;
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603163851.18058-1-leontyevantony@gmail.com?part=1
next prev parent reply other threads:[~2026-06-04 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 15:52 [PATCH net] hv_netvsc: use kmap_local_page in netvsc_copy_to_send_buf LeantionX
2026-06-02 22:54 ` [EXTERNAL] " Haiyang Zhang
2026-06-03 5:29 ` Anton Leontev
2026-06-03 15:53 ` sashiko-bot
2026-06-03 16:29 ` Anton Leontev
2026-06-03 16:38 ` [PATCH net v2] " Anton Leontev
2026-06-04 16:39 ` sashiko-bot [this message]
2026-06-04 16:59 ` Anton Leontev
-- strict thread matches above, loose matches on Subject: below --
2026-06-03 17:25 Anton Leontev
2026-06-04 17:25 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260604163900.A09211F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leontyevantony@gmail.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox