πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27167

Re: [PATCH net 07/10] net: kunit: test unreadable net_iov napi_gro_frags

#27167
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 22:07
129 lines
12675 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In net/core/net_test.c, netmem_unreadable_test_napi_reuse() is
  meant to show that napi_reuse_skb() clears skb->unreadable and…

--

net: kunit: test unreadable net_iov napi_gro_frags

This commit adds two KUnit tests to net_test that cover unreadable net_iov
skbs going through napi_gro_frags(). The first test checks that a header
pull failure in napi_frags_skb() frees the skb without leaking references.
The second test checks that napi_reuse_skb() clears unreadable and
pp_recycle on the skb it caches on napi->skb.

> diff --git a/net/core/net_test.c b/net/core/net_test.c
> index 47f5dc0fa5cf6..b939cc93e9050 100644
> --- a/net/core/net_test.c
> +++ b/net/core/net_test.c

[ ... ]

> @@ -1720,6 +1724,244 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)

[ ... ]

> +static void netmem_unreadable_test_napi_reuse(struct kunit *test)
> +{
> +	struct netmem_unreadable_env *env = netmem_unreadable_env_init(test);
> +	struct gro_test_napi_ctx *ctx = alloc_gro_test_napi(test);
> +	struct napi_struct *napi = &ctx->napi;
> +	gro_result_t ret1 = GRO_NORMAL, ret2 = GRO_NORMAL;
> +	bool readable = false, pp_recycle = true;
> +	struct sk_buff *skb;
> +
> +	/* Merge two unreadable pp_recycle segments via napi_gro_frags() so
> +	 * napi_reuse_skb() caches the second skb on napi->skb, then verify
> +	 * the cached skb has unreadable and pp_recycle cleared.
> +	 * napi_get_frags() and napi_gro_frags() require BH-disabled context.
> +	 */
> +	local_bh_disable();
> +	skb = napi_get_frags(napi);
> +	if (!skb)
> +		goto out_bh;
> +	fill_tcp4_headers(skb, htonl(0xc0000201), htonl(0xc0000202),
> +			  htons(10000), htons(20000), 1000, 1, 64);
> +	netmem_unreadable_add_frag(skb, env, 0, 64);
> +	ret1 = napi_gro_frags(napi);
> +
> +	skb = napi_get_frags(napi);
> +	if (!skb)
> +		goto out_bh;
> +	fill_tcp4_headers(skb, htonl(0xc0000201), htonl(0xc0000202),
> +			  htons(10000), htons(20000), 1064, 1, 64);
> +	netmem_unreadable_add_frag(skb, env, 64, 64);
> +	ret2 = napi_gro_frags(napi);
> +
> +	skb = napi_get_frags(napi);
> +	if (skb) {
> +		readable = skb_frags_readable(skb);
> +		pp_recycle = skb->pp_recycle;
> +	}

[Severity: Low]
Can this check pass without napi_reuse_skb() ever caching the second skb?

Nothing confirms that the skb from the third napi_get_frags() is the same
object as the second segment. napi_frags_finish() can also handle
GRO_MERGED_FREE without caching anything:

net/core/gro.c:napi_frags_finish() {
    ...
	case GRO_MERGED_FREE:
		if (NAPI_GRO_CB(skb)->free == NAPI_GRO_FREE_STOLEN_HEAD)
			napi_skb_free_stolen_head(skb);
		else
			napi_reuse_skb(napi, skb);
		break;
    ...
}

napi_reuse_skb() can also exit early and free the skb:

net/core/gro.c:napi_reuse_skb() {
	...
	if (unlikely(skb->pfmemalloc)) {
		consume_skb(skb);
		return;
	}
	...
}

On either path napi->skb stays NULL. The third napi_get_frags() then
returns a fresh skb from napi_alloc_skb(), and that skb already has
unreadable and pp_recycle cleared. The checks on readable and pp_recycle
would pass even though the reset was never tested.

The ret2 == GRO_MERGED_FREE check can't tell these cases apart, because
all three paths return GRO_MERGED_FREE.

With the current skb_gro_receive() and the linear headers built by
fill_tcp4_headers(), the packet should take the NAPI_GRO_FREE branch, so
normal runs do exercise the reuse path. The gap appears only if the second
skb is pfmemalloc, or if a later GRO change sends this case down the
stolen-head path.

Would it help to save the second skb pointer and add
KUNIT_EXPECT_PTR_EQ() against the third napi_get_frags() result? Checking
that napi->skb is non-NULL before the third napi_get_frags() would also
work.

> +out_bh:
> +	local_bh_enable();
> +
> +	KUNIT_ASSERT_NOT_NULL(test, skb);
> +	KUNIT_EXPECT_EQ(test, ret1, GRO_HELD);
> +	KUNIT_EXPECT_EQ(test, ret2, GRO_MERGED_FREE);
> +	KUNIT_EXPECT_TRUE(test, readable);
> +	KUNIT_EXPECT_FALSE(test, pp_recycle);

[ ... ]

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com
Technical Details
Message-ID: <179642207739.3146.15508684489315403404@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377691-linux-kernel-netdev=dewy.ru
References: <1268787de8c80ea8c579d345843cd060418bee32.1796329894.git.tavip@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377691-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 07/10] net: kunit: test unreadable net_iov napi_gro_frags
Date: Fri, 04 Dec 2026 22:07:57 +0000
Organization: Usenet Network
Message-ID: <179642207739.3146.15508684489315403404@kernel.org>
References: <1268787de8c80ea8c579d345843cd060418bee32.1796329894.git.tavip@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2884222"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:a2vTBXcSx2PAS6FkF0oe0BI0Cz8= sha256:/9RFXaW/segsz4QaFCJ0dT9QAaZdoW5w8I92Vc0sW9A=
	sha1:EfixaLPUL8+3mOkovcIqqAtmG0M= sha256:8LyeHYH7Vqv4ZGuxxl2kAl7dKRzXk3mvMalKMKyrDFg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 06B4A117D11; Sat,  5 Dec 2026 01:08:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id pWCXtMSQAa-V;
	Sat,  5 Dec 2026 01:08:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377691-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id EDD57117D0B; Sat,  5 Dec 2026 01:08:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CAC433481A; Fri,  4 Dec 2026 22:08:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796422085;
	b=2oNLVIeyEe3Mg9bg7gzYbFhDG1/gRMU9U7+/dyGvjfPRa1n1ZxAUmTOIbxqqJ9lLSOj/
	 zex9Mh2VSHoOyKNQ5jaIy3wMXy+gCViSLMwYUmnm/FMKQ8AiP8TA4/gPEwBHG3rcr1WSu
	 YdmH3ZllvQvSp3MN4uHrxQnZPhG2oMOzDXI+TIbhptPkKC2VQ3QaKcrSoCZbJb1sbUeAv
	 5upPVPYBBIDwQYsD2npXevFAhYD5HYmliw7eF3uKid0HHvwtuKYfkor/f9dDM78Etq45x
	 1rgW6mvi+iMh3DxIZGLoVvB8h9cvR7CoaI/HFOlALzO2GjLGMuLkEMH4eM2458+U39A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796422085;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=kLdQxq6oKGqLWKXFV79R+e+BuN9oInMDa/uBOUBGfEk=;
	b=0PcJ6wxCyyhyBw2bvQy3AuItljm1DwLCIkLcRShK+1XIWI5oGOIkKNJE7JOlAgl3uCrv
	 hS/Kf2g8xpaYb1gDkUqQaVgR1CzMB/xJRaLW5lo/EKfSCp+m+QF61H48swspqVbjAVOas
	 wZdMrSMEW7reobTmBGkJIJN7iYhqSqe4hLmzdWHKTH4mGu/592VMmdena1lJ98/DVEA/r
	 xRRfAJRNtFS2d5F1bOmceZ+WN70bkR5yiNq6JuzACLCpTbWWPzznWuYoYP2XtBIaSsHKA
	 +BIhN0oBXzGiaLutdKythcNpWJWIpa11AmFj7Lk+326F8nrSpRmg2lnbT7A1vw2N7BQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LNdgn6b2;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E099606A685;
	Fri,  4 Dec 2026 22:08:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LNdgn6b2
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796422079;
	b=prX2KPxc9HUAEqI84ljdrhi+aJ4I1moib/3uQUgo5ia8oq49H0uqEcL5VEIbodOlDULZ
	 cC/njWpJ76chWceJu6tJIT5oucwPa383NyOlZ3wAq3esqRukSMdacszLscrj92PzIEGzJ
	 VVWbT0lxivxtwUX1suyN1j3XD7Nlc+eZ4UjF7+B4TN4WjBdSUf8pYrZiyvLSuVzhMadS+
	 IIJxtE4cjPB/yf5t1+TXPeGElFGR5DAuoFmGdVg2OgXcv3534MlTnU5WfJSM75/4OlbyP
	 n4Xp3mNeLr7rkgYjZMPI0RLdezKB59ut32sjvU11gNVBbWNp6PGq6zXyvqXSxg55TWA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796422079;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=kLdQxq6oKGqLWKXFV79R+e+BuN9oInMDa/uBOUBGfEk=;
	b=ra0d3M0D8trd5QJfOyEqCsu8rNIDmG1ipCBvouBgX1AzdjtfSKgkNAv/ZaRFRPxfwFQ6
	 v+BiGjDnfN76CSLIF/igh7UdZfm+Fn2DWCjWcMRAVc6GxH3fmxaFWVJpZAMPQ7EgyUELt
	 Cgi86WTs++Y3UHsybs4ny05PAMFtGlbEKT2p9MYSdYk0XKYb2r49MbcmNxTToZ1bB1bM3
	 lLnd3AEJuSZ177PJnfsO5UFg77c6dXbFAnprbUJvZkdiO/X2jwZpKwDxiiAxn+TPu05AO
	 zcHFU7O5/KgZzhbCaKUPr16Tn2xq63jYL3Qajg0nO5eSjmX5NZlqipFOQCvwdCK5vlQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LNdgn6b2;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DCE9606A32F;
	Fri,  4 Dec 2026 22:07:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5F881F00A12;
	Fri,  4 Dec 2026 22:07:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796422079;
	bh=kLdQxq6oKGqLWKXFV79R+e+BuN9oInMDa/uBOUBGfEk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=LNdgn6b2VMpj0uj5waiJ9olMwjd+iYKH5Ha5WwAobi3MK1eEeS9PPDSv3bU8B3DDc
	 WdFdQryc7evjgyeLOnwD2RLZaymcJUUidEbDb+d7vJU3kadlD4gm+ju+tk56KUN/7a
	 gdbLeBetXgmwizyo1CO6Ykx0pvFyjJ8+0JDeg1mPetz6cHfs3/spOQcbgBnxIfOR8c
	 rjJNMwTAw1RNjS2bsjPeLiV8LTl2zd9+aduUF5UPQ8zuzRNL9d781R8AL+KZ6JUdxc
	 9DLaGRKYa6TxH4+5v9zidalTADF3zCzPnwUjSGEydSDYexMU9ok91zLFjffMLpkxRL
	 ycCqQACn3Bf9A==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org,
 andrew+netdev@lunn.ch, ncardwell@google.com, kuniyu@google.com,
 dsahern@kernel.org, idosch@nvidia.com, john.fastabend@gmail.com,
 jakub@cloudflare.com, jiayuan.chen@linux.dev, sd@queasysnail.net,
 shuah@kernel.org, almasrymina@google.com, sdf@fomichev.me,
 kaiyuanz@google.com, ilias.apalodimas@linaro.org, hawk@kernel.org,
 mcroce@microsoft.com, herbert@gondor.apana.org.au, ecree.xilinx@gmail.com,
 bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
X-In-Reply-To: <1268787de8c80ea8c579d345843cd060418bee32.1796329894.git.tavip@google.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list