From: netdev-bot+sashiko@kernel.org
To: tavip@google.com
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
Subject: Re: [PATCH net 08/10] net: kunit: test unreadable net_iov defrag and skb helpers
Date: Fri, 04 Dec 2026 22:07:59 +0000 [thread overview]
Message-ID: <179642207933.3146.17718828051155213496@kernel.org> (raw)
In-Reply-To: <7cd1ee7c97bba0d276b9a09aa7cdfa38b08c96cc.1796329894.git.tavip@google.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] netmem_unreadable_test_ip_defrag() (net/core/net_test.c) puts
fragment skbs into the global init_net reassembly queues: the IPv4…
- [Low] The commit "net: skbuff, skmsg, strparser: reject unreadable
frags" says it was "reproduced and verified with the accompanying…
- [Low] The Netfilter IPv6 sub-cases of
netmem_unreadable_test_ip_defrag() are wrapped in `#if…
- [Low] The IPv4 part of netmem_unreadable_test_ip_defrag() reassembles
in the live init_net ipfrag fqdir with fixed keys.
--
net: kunit: test unreadable net_iov defrag and skb helpers
This commit adds KUnit tests to net_test for unreadable net_iov handling
in IPv4 and Netfilter IPv6 fragment reassembly, skb_to_sgvec(),
skb_send_sock_locked() and strparser. The tests also check that the
page_pool and binding reference counts stay balanced.
> diff --git a/net/core/net_test.c b/net/core/net_test.c
> index b939cc93e9050..8da6c5ab4430c 100644
> --- a/net/core/net_test.c
> +++ b/net/core/net_test.c
[ ... ]
> @@ -1962,6 +1971,377 @@ static void netmem_unreadable_test_napi_reuse(struct kunit *test)
[ ... ]
> +static struct sk_buff *alloc_ipv4_frag_skb(u16 id, u16 frag_off)
> +{
[ ... ]
> + iph->id = htons(id);
> + iph->protocol = IPPROTO_UDP;
> + iph->saddr = htonl(0x7f000001);
> + iph->daddr = htonl(0x7f000001);
[Severity: Low]
These fragments go into the live init_net ipfrag fqdir with a fixed key.
The key is saddr = daddr = 127.0.0.1, protocol UDP, IDs 0x4242 to 0x4245,
and user IP_DEFRAG_LOCAL_DELIVER. Also, netmem_unreadable_test_ip_defrag()
re-enables BH between the two ip_defrag() calls.
Can real local-delivery fragments with the same key join or disturb the
test's queue in that window? Loopback UDP with a reduced lo MTU or locally
injected raw fragments could do this.
If a readable real fragment lands in one of the test's unreadable queues,
the mixed-readability check drops the real packet and the test result is
wrong. A queue left over from an earlier failed run with the same ID could
also break the next run.
The IPv6 sub-cases don't seem to have this problem. The in-tree callers of
nf_ct_frag6_gather() all use conntrack-range users rather than 0.
Would a dedicated netns, or less predictable addresses or IDs, isolate
these tests?
> +#if IS_REACHABLE(CONFIG_NF_DEFRAG_IPV6)
> +static struct sk_buff *alloc_ipv6_frag_skb(u32 id, u16 frag_off)
[ ... ]
> +static void netmem_unreadable_test_ip_defrag(struct kunit *test)
> +{
> + struct netmem_unreadable_env *env = netmem_unreadable_env_init(test);
> + struct sk_buff *frag1, *frag2, *child;
> + int err;
> +
> + /* IPv4: readable first fragment + unreadable second fragment must fail
> + * and tear down the fragment queue.
> + */
[ ... ]
> + local_bh_disable();
> + err = ip_defrag(&init_net, frag2, IP_DEFRAG_LOCAL_DELIVER);
> + local_bh_enable();
> + KUNIT_EXPECT_EQ(test, err, -EINVAL);
> + if (!err)
> + consume_skb(frag2);
[Severity: Medium]
What happens to the queued fragments if this second ip_defrag() call
returns -EINPROGRESS?
KUNIT_EXPECT_EQ() doesn't abort the test. The live queue still owns
fragments that hold page_pool references to env->niov, and nothing in the
test kills that queue. At teardown, netmem_unreadable_env_cleanup() runs:
netmem_clear_pp_magic(env->niov_nm);
netmem_set_pp(env->niov_nm, NULL);
page_pool_destroy(env->pool);
percpu_ref_exit(&env->binding.ref);
KUnit then frees env, and with it the embedded struct net_iov.
When the frag queue timer fires later (ipfrag_time for IPv4,
IPV6_FRAG_TIMEOUT for nf IPv6), the purge path would run:
inet_frag_rbtree_purge()
kfree_skb()
skb_release_data()
napi_pp_put_page()
Wouldn't that read the freed niov and binding memory from softirq context,
possibly after net_test.ko has been unloaded?
This doesn't need a kernel regression to happen. ip_frag_queue() checks
ip_frag_too_far() before the readability check:
if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) &&
unlikely(ip_frag_too_far(qp)) &&
unlikely(err = ip_frag_reinit(qp))) {
Suppose more than ipfrag_max_dist fragments from 127.0.0.1 are processed
between the two calls. ip_frag_reinit() then resets the queue, frag2 is
queued alone, and ip_frag_queue() returns -EINPROGRESS. A regression in
the reassembly code under test that leaves the queue incomplete would have
the same result.
The other IPv4 sub-cases that expect 0 and the nf_ct_frag6_gather()
sub-cases follow the same pattern. Could the test make sure any remaining
queue is killed before the env is torn down?
[ ... ]
> +#if IS_REACHABLE(CONFIG_NF_DEFRAG_IPV6)
> + /* Netfilter IPv6: mixed readability must fail and kill the queue. */
[Severity: Low]
NF_DEFRAG_IPV6 is a promptless tristate. With NET_TEST=y and
NF_DEFRAG_IPV6=m, IS_REACHABLE() is false and this block is compiled out.
NET_TEST in net/Kconfig only depends on KUNIT and selects neither option.
The CONFIG_STREAM_PARSER block in netmem_unreadable_test_sg_and_strp() has
the same issue. STREAM_PARSER is def_bool n and is only enabled when
BPF_STREAM_PARSER, AF_KCM or ESPINTCP selects it.
In those configs, netmem_unreadable_test_ip_defrag() and
netmem_unreadable_test_sg_and_strp() still report PASS without running the
IPv6 or strparser checks. Would an #else branch with kunit_mark_skipped(),
or a Kconfig dependency for NET_TEST, make that visible?
[ ... ]
> +static void netmem_unreadable_test_sg_and_strp(struct kunit *test)
> +{
[Severity: Low]
This isn't a bug in this patch. It concerns the earlier commit in the
series, "net: skbuff, skmsg, strparser: reject unreadable frags", which
says it was:
"reproduced and verified with the accompanying net_test KUnit tests"
This test covers skb_to_sgvec(), skb_send_sock_locked(), and strp_recv()
through strp_data_ready(). It doesn't reach the skmsg changes in that
commit:
- the new reject branch in sk_psock_verdict_apply(), which reports EFAULT
and clears SK_PSOCK_TX_ENABLED
- the new -EMSGSIZE propagation in sk_psock_skb_ingress_enqueue()
No psock is created anywhere in net/core/net_test.c.
Should that commit message say what the tests actually cover, or should
sockmap coverage be added here?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com
next prev parent reply other threads:[~2026-12-04 22:08 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 21:09 [PATCH net 00/10] net: fix unreadable net_iov skb handling across networking paths Octavian Purdila
2026-12-03 21:09 ` [PATCH net 01/10] net: gro: free skb on napi_frags_skb() header pull failure Octavian Purdila
2026-12-04 18:31 ` Mina Almasry
2026-12-03 21:09 ` [PATCH net 02/10] net: gro: reset unreadable and pp_recycle in napi_reuse_skb Octavian Purdila
2026-12-04 18:32 ` Mina Almasry
2026-12-04 21:07 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly Octavian Purdila
2026-12-04 18:38 ` Mina Almasry
2026-12-04 21:09 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 04/10] net: skbuff, skmsg, strparser: reject unreadable frags Octavian Purdila
2026-12-04 18:58 ` Mina Almasry
2026-12-04 21:25 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 05/10] tls: reject unreadable skbs in tls_strp Octavian Purdila
2026-12-04 18:44 ` Mina Almasry
2026-12-04 22:24 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 06/10] tcp: reject unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 18:46 ` Mina Almasry
2026-12-04 22:26 ` Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 07/10] net: kunit: test unreadable net_iov napi_gro_frags Octavian Purdila
2026-12-04 18:47 ` Mina Almasry
2026-12-04 22:07 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 08/10] net: kunit: test unreadable net_iov defrag and skb helpers Octavian Purdila
2026-12-04 22:07 ` netdev-bot+sashiko [this message]
2026-12-03 21:09 ` [PATCH net 09/10] selftests: drv-net: devmem: test unreadable kTLS RX Octavian Purdila
2026-12-04 18:48 ` Mina Almasry
2026-12-04 22:28 ` Octavian Purdila
2026-12-04 22:08 ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 22:08 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179642207933.3146.17718828051155213496@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jakub@cloudflare.com \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kaiyuanz@google.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=mcroce@microsoft.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=tavip@google.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox