From: sashiko-bot@kernel.org
To: "Mahe Tardy" <mahe.tardy@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v6 6/6] selftests/bpf: add bpf_icmp_send recursion test
Date: Mon, 18 May 2026 17:07:39 +0000 [thread overview]
Message-ID: <20260518170739.A3626C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260518122842.218522-7-mahe.tardy@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The BPF program `recursion` acts as a global drop-all firewall for host IPv4 traffic, causing severe network disruption and test flakiness.
--
commit d88b16de11be32b864006f6686e0acf06d339e51
Author: Mahe Tardy <mahe.tardy@gmail.com>
selftests/bpf: add bpf_icmp_send recursion test
This commit adds a test to verify that the bpf_icmp_send kfunc stops early
and returns -EBUSY when triggered recursively. The test attaches a BPF
program to the root cgroup to intercept the kernel-generated ICMP packet.
> diff --git a/tools/testing/selftests/bpf/progs/icmp_send.c b/tools/testing/selftests/bpf/progs/icmp_send.c
> index 6e1ba539eeb0f..7830334b747ac 100644
> --- a/tools/testing/selftests/bpf/progs/icmp_send.c
> +++ b/tools/testing/selftests/bpf/progs/icmp_send.c
[ ... ]
> @@ -65,4 +68,32 @@ int egress(struct __sk_buff *skb)
> return SK_DROP;
> }
>
> +SEC("cgroup_skb/egress")
> +int recursion(struct __sk_buff *skb)
> +{
> + void *data = (void *)(long)skb->data;
> + void *data_end = (void *)(long)skb->data_end;
> + struct iphdr *iph;
> + int ret;
> +
> + iph = data;
> + if ((void *)(iph + 1) > data_end || iph->version != 4)
> + return SK_PASS;
> +
> + /* This call will provoke a recursion: the ICMP packet generated by the
> + * kfunc will re-trigger this program since we are in the root cgroup in
> + * which the kernel ICMP socket belongs. However when re-entering the
> + * kfunc, it should return EBUSY.
> + */
> + ret = bpf_icmp_send(skb, unreach_type, unreach_code);
> + rec_kfunc_rets[rec_count & 1] = ret;
> + __sync_fetch_and_add(&rec_count, 1);
> +
> + /* Let the first ICMP error message pass */
> + if (iph->protocol == IPPROTO_ICMP)
> + return SK_PASS;
> +
> + return SK_DROP;
> +}
Since this program is attached to the global root cgroup, does it act as a
global drop-all firewall for host IPv4 traffic?
If any background traffic occurs while this test runs, it appears it will be
unconditionally dropped here.
Could this also cause test flakiness? If concurrent background traffic
triggers this program, it would race with the test traffic and overwrite the
rec_kfunc_rets array, leading to unexpected values in the test assertions.
Should the program explicitly filter packets, for example by checking
iph->daddr or iph->protocol, to ensure it only processes the test's intended
traffic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518122842.218522-1-mahe.tardy@gmail.com?part=6
prev parent reply other threads:[~2026-05-18 17:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 12:28 [PATCH bpf-next v6 0/4] bpf: add icmp_send kfunc Mahe Tardy
2026-05-18 12:28 ` [PATCH bpf-next v6 1/6] net: move netfilter nf_reject_fill_skb_dst to core ipv4 Mahe Tardy
2026-05-18 13:07 ` bot+bpf-ci
2026-05-18 14:21 ` Mahe Tardy
2026-05-18 12:28 ` [PATCH bpf-next v6 2/6] net: move netfilter nf_reject6_fill_skb_dst to core ipv6 Mahe Tardy
2026-05-18 13:07 ` bot+bpf-ci
2026-05-18 14:22 ` Mahe Tardy
2026-05-18 12:28 ` [PATCH bpf-next v6 3/6] bpf: add bpf_icmp_send kfunc Mahe Tardy
2026-05-18 13:34 ` bot+bpf-ci
2026-05-18 14:26 ` Mahe Tardy
2026-05-18 16:17 ` Stanislav Fomichev
2026-05-18 17:18 ` Mahe Tardy
2026-05-19 21:20 ` Stanislav Fomichev
2026-05-18 16:25 ` sashiko-bot
2026-05-19 1:33 ` Jordan Rife
2026-05-18 12:28 ` [PATCH bpf-next v6 4/6] selftests/bpf: add bpf_icmp_send kfunc tests Mahe Tardy
2026-05-19 1:34 ` Jordan Rife
2026-05-18 12:28 ` [PATCH bpf-next v6 5/6] selftests/bpf: add bpf_icmp_send kfunc IPv6 tests Mahe Tardy
2026-05-18 13:21 ` bot+bpf-ci
2026-05-18 14:27 ` Mahe Tardy
2026-05-18 16:45 ` sashiko-bot
2026-05-18 18:13 ` Mahe Tardy
2026-05-18 12:28 ` [PATCH bpf-next v6 6/6] selftests/bpf: add bpf_icmp_send recursion test Mahe Tardy
2026-05-18 13:07 ` bot+bpf-ci
2026-05-18 14:39 ` Mahe Tardy
2026-05-18 17:07 ` sashiko-bot [this message]
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=20260518170739.A3626C2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=mahe.tardy@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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