Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3031210pxa; Tue, 18 Aug 2020 05:00:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTvrJNqoBTMoQI6JR5Y0X38zZ3peVAQ0TwDsUwlH9idKp5DSImoAsE1JiNSSKai5YOdcni X-Received: by 2002:a17:906:6bda:: with SMTP id t26mr20376409ejs.214.1597752006493; Tue, 18 Aug 2020 05:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597752006; cv=none; d=google.com; s=arc-20160816; b=yfT4Eu19Fx8E3z8TzxRYFtkQ+5Bc8fdAec5Pkt5QE1xqaMgV6xZ58uer/DyQTXimyb +PmjuOsTU+YUQXTIPRK5pRh4knnVn/yxKBvtNLy4WMUoA9LNKvrgDzcFTizE6D7zfcHC YW73x1ac/XTgec6utfskyhYGiKuH7VhXOc+kHJbSyL+l8ZJU/j09WCkXz2xXtLGAQZMM skXFcVOBEWm9hiM4dv9BlyHEEeT7A5crbg1/311ppI6tOiEW4jmzmMGBFla58mkYHEb6 lctKRt2iixNdTy+22R7eOFTXa8Q6HEDv/Fu6Jj8JupwnoQsP+NWgqqPbW/TpbfEDsvQ/ sIow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=73cSQNGTNvtPgxfUj3cyIz/+Uq89Y7hM0pUYR+cYpu8=; b=IHdLPz8zlIrrS2JUSCNb+8yQTutBZo445Lj/Vv+8iVgTm/POv6+uKXW3hImoRbaOiv qFUjUdKrgXB9bsunMktNrA82pAZ1b0DeS4kHzKLPigZ7MQU9afr1ub08kWkHKt4Re6Rg zyv8uKbvK95ZNnkGjDmdOPSxNCaoIrfvPbb9LDMfvi+eJOw0tf1ax6ki8/msR8kSv64U qk9MJgZn/BUsx73isuozdBdtjV4eAdoJmfIjX5P9Fr7k7Qkfillb/oKJepw1iRU2ZpRn k4HkSOcESmr2MKKg2W2FUOQrIKim0wU1VsUkSBho+MtMEY0Yl0bjWRkQsLgT4aYkD5Kr NNQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si10662880eds.451.2020.08.18.04.59.42; Tue, 18 Aug 2020 05:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726616AbgHRL6e (ORCPT + 99 others); Tue, 18 Aug 2020 07:58:34 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9835 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726370AbgHRL6d (ORCPT ); Tue, 18 Aug 2020 07:58:33 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 20A847032FD65771EB2D; Tue, 18 Aug 2020 19:58:28 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Tue, 18 Aug 2020 19:58:18 +0800 From: Miaohe Lin To: , , , , , , , , , , CC: , , Subject: [PATCH] net: Relax the npages test against MAX_SKB_FRAGS Date: Tue, 18 Aug 2020 07:57:12 -0400 Message-ID: <20200818115712.36497-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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