lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231113130041.58124-5-linyunsheng@huawei.com>
Date: Mon, 13 Nov 2023 21:00:36 +0800
From: Yunsheng Lin <linyunsheng@...wei.com>
To: <davem@...emloft.net>, <kuba@...nel.org>, <pabeni@...hat.com>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Yunsheng Lin
	<linyunsheng@...wei.com>
Subject: [PATCH RFC 4/8] skbuff: explicitize the semantics of skb_frag_fill_page_desc()

As we have ensured that the page and the offset to the page
for the skb frag is passed togetherly in one function call,
see [1], make it explicit that skb_frag_fill_page_desc()
expect a base page or head page for a compound page, so
that we can avoid the compound_head() in the net stack.

Log a warning if the caller passes a tail page of compoud
page and adjust 'page' to point to it's head page and
'offset' to point to start of it's head page. The warning
can be removed if we have ensured all the caller is passing
non tail page to skb_frag_fill_page_desc() in the future.

1. https://lore.kernel.org/all/20230511011213.59091-2-linyunsheng@huawei.com/

Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com>
---
 include/linux/skbuff.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 27998f73183e..3e2f806c8ed8 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2423,6 +2423,14 @@ static inline void skb_frag_fill_page_desc(skb_frag_t *frag,
 					   struct page *page,
 					   int off, int size)
 {
+	/* expect head page for compound page */
+	if (WARN_ON_ONCE(PageTail(page))) {
+		struct page *head = compound_head(page);
+
+		off += (page_to_pfn(page) - page_to_pfn(head)) * PAGE_SIZE;
+		page = head;
+	}
+
 	frag->bv_page = page;
 	frag->bv_offset = off;
 	skb_frag_size_set(frag, size);
-- 
2.33.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ