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/cove…%40google.com