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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 18 Aug 2020 07:57:12 -0400
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>,
        <martin.varghese@...ia.com>, <fw@...len.de>, <pshelar@....org>,
        <dcaratti@...hat.com>, <edumazet@...gle.com>,
        <steffen.klassert@...unet.com>, <pabeni@...hat.com>,
        <shmulik@...anetworks.com>, <kyk.segfault@...il.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linmiaohe@...wei.com>
Subject: [PATCH] net: Relax the npages test against MAX_SKB_FRAGS

The npages test against MAX_SKB_FRAGS can be relaxed if we succeed to
allocate high order pages as the note in comment said.

Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
---
 net/core/skbuff.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2f7dd689bccc..ca432bbfd90b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5758,13 +5758,6 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
 	struct page *page;
 	int i;
 
-	*errcode = -EMSGSIZE;
-	/* Note this test could be relaxed, if we succeed to allocate
-	 * high order pages...
-	 */
-	if (npages > MAX_SKB_FRAGS)
-		return NULL;
-
 	*errcode = -ENOBUFS;
 	skb = alloc_skb(header_len, gfp_mask);
 	if (!skb)
@@ -5775,6 +5768,10 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
 	for (i = 0; npages > 0; i++) {
 		int order = max_page_order;
 
+		if (unlikely(i >= MAX_SKB_FRAGS)) {
+			*errcode = -EMSGSIZE;
+			goto failure;
+		}
 		while (order) {
 			if (npages >= 1 << order) {
 				page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) |
-- 
2.19.1

Powered by blists - more mailing lists