Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B8A219F11B for ; Mon, 15 Jun 2026 18:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781546522; cv=none; b=DpbaHunvKO17nCgMaH8DO8k3aXH6zN+B4d4/YKflDQ662UYkUqmMmUMe5tJZmCXxG99SHTWTGk2WV6jE+pBEilBK4Ri4gHYSjaSuPj/D9bRpqe2fs7htScmlRtL/NMUV5fvYrd14sjNnj7hkjCnyQqQFFqREoA+ep3hcH25xjfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781546522; c=relaxed/simple; bh=q7+gClvS2TW9D8ummv6eyvhMzS/vGgtzgPolqSxmFoc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i2F46sZUXl1Mjb/yjHUvm3bmu0le9vspWKFojlxuBGPTSUqq27qxI1ucz1jWkSwdHdrh2Bv1ZX2sOGDu0bDeCKhzBTVn9SnTFYrBL//NSqB8S1wBlXEeKY718+Ty41wRvOgcq6SA+qzVgCLkNlxYasDjLZKz71w6pi1/xic2084= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L2S7UhVK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L2S7UhVK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 638801F000E9; Mon, 15 Jun 2026 18:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781546520; bh=IhD8WqABXZXBHNVx5PGSp+U6dNOT2TQ1qqBFHwghUSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L2S7UhVKfq98laS4MGN9xwcarOrj5PpcwcC6MbgxZAMKmt4lCzgwpnF2lCbsh5plh 0sxDU51cLI17OHSXkRTaFgDF63t/PNz5nP67j4Ax9gEpHifynpJE9ubZx4dCV9ipcR SbTTMuGO6pMuyQlLXQ3RdqiDDMIOqFdYHT90MScga2Jg6u451LGWTy9Jw3iqbCDC9i xmE9rxFPwhKcZfmJd6Nk96H7AprldrvPobxP3qP20V/lOLVDc0/ovmeFPtBBGY8eNh fvrlVL5EheVm30nK4DLhDWB+6SKSqpcws62bnOmtjclhndQRsEqrkzbnrDb2VdcVtC lwUoxPqagCTfg== From: Sasha Levin To: stable@vger.kernel.org Cc: Anton Leontev , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12.y] hv_netvsc: use kmap_local_page in netvsc_copy_to_send_buf Date: Mon, 15 Jun 2026 14:01:58 -0400 Message-ID: <20260615180158.2315829-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026061523-ergonomic-illusive-5c64@gregkh> References: <2026061523-ergonomic-illusive-5c64@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Anton Leontev [ Upstream commit 004e9ecfe6c5384f9e0b2f6f6389d42ec22789af ] netvsc_copy_to_send_buf() copies page buffer entries into the VMBus send buffer using phys_to_virt() on the entry PFN. Entries for the RNDIS header and the skb linear data come from kmalloc'd memory and are always in the kernel direct map, but entries for skb fragments reference page cache or user pages, which on 32-bit x86 with CONFIG_HIGHMEM=y can live above the LOWMEM boundary. For such a page phys_to_virt() returns an address outside the direct map and the subsequent memcpy() faults on the transmit softirq path, which is fatal. Map the pages with kmap_local_page() instead, handling two properties of the page buffer entries: - pb[i].pfn is a Hyper-V PFN at HV_HYP_PAGE_SIZE (4K) granularity, not a native PFN. Reconstruct the physical address first and derive the native page from it, so the mapping stays correct where PAGE_SIZE > HV_HYP_PAGE_SIZE (e.g. arm64 with 64K pages). - Since commit 41a6328b2c55 ("hv_netvsc: Preserve contiguous PFN grouping in the page buffer array"), an entry describes a full physically contiguous fragment and pb[i].len can exceed PAGE_SIZE, while kmap_local_page() maps a single page. Copy page by page, splitting at native page boundaries. The copy path only handles packets smaller than the send section size (6144 bytes by default); larger packets take the cp_partial path where only the RNDIS header is copied. So entries here are bounded by the section size and a copy is split at most once on 4K-page systems. On !CONFIG_HIGHMEM configs kmap_local_page() folds to page_address() and no mapping work is added. Fixes: c25aaf814a63 ("hyperv: Enable sendbuf mechanism on the send path") Cc: stable@vger.kernel.org Signed-off-by: Anton Leontev Link: https://patch.msgid.link/20260604165938.32033-1-leontyevantony@gmail.com Signed-off-by: Paolo Abeni [ adapted `phys_to_page(paddr)` to `pfn_to_page(PHYS_PFN(paddr))` ] Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 5f14799b68c532..ff04364c9d975c 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -964,12 +965,22 @@ 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) + + pb[i].offset; u32 len = pb[i].len; - memcpy(dest, (src + offset), len); - dest += len; + while (len) { + struct page *page = pfn_to_page(PHYS_PFN(paddr)); + u32 off = offset_in_page(paddr); + u32 chunk = min_t(u32, len, PAGE_SIZE - off); + char *src = kmap_local_page(page); + + memcpy(dest, src + off, chunk); + kunmap_local(src); + dest += chunk; + paddr += chunk; + len -= chunk; + } } if (padding) -- 2.53.0