From: sashiko-bot@kernel.org
To: "Amery Hung" <ameryhung@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 14/15] selftests/bpf: Test attaching struct_ops to a cgroup
Date: Wed, 24 Jun 2026 00:03:12 +0000 [thread overview]
Message-ID: <20260624000312.AD6581F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623175006.3136053-15-ameryhung@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Test state pollution in the `inherit` subtest bypasses the intended `cgroup_bpf_inherit()` testing path because the child cgroup persists from the previous `hierarchy` subtest.
--
commit 9dd80df6f86c72623dac7d2f203da4036e4e8827
Author: Martin KaFai Lau <martin.lau@kernel.org>
Subject: selftests/bpf: Test bpf_tcp_ops cgroup generic link
This commit adds selftests for attaching bpf_tcp_ops struct_ops to cgroups via
the generic cgroup link infrastructure. The tests validate various behaviors
including execution order, query interfaces, updates, and inheritance.
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ops.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ops.c
> new file mode 100644
> index 000000000000..4d087bdc4613
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ops.c
[ ... ]
> +static void run_hierarchy_subtest(void)
> +{
> + struct bpf_tcp_ops *skel = NULL;
> + struct netns_obj *ns = NULL;
> + int parent_fd, child_fd = -1;
> +
> + parent_fd = test__join_cgroup(CGROUP_PATH);
> + if (!ASSERT_GE(parent_fd, 0, "join_parent_cgroup"))
> + return;
> +
> + child_fd = create_and_get_cgroup(CGROUP_PATH "/child");
> + if (!ASSERT_GE(child_fd, 0, "create_child_cgroup"))
> + goto done;
> +
> + if (!ASSERT_OK(join_cgroup(CGROUP_PATH "/child"), "join_child_cgroup"))
> + goto done;
> +
> + ns = netns_new(TEST_NETNS, true);
> + if (!ASSERT_OK_PTR(ns, "netns_new"))
> + goto done;
> +
> + skel = bpf_tcp_ops__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "open_and_load"))
> + goto done;
> +
> + test_hierarchy(parent_fd, child_fd, skel);
> +
> +done:
> + bpf_tcp_ops__destroy(skel);
> + netns_free(ns);
> + if (child_fd >= 0)
> + close(child_fd);
> + close(parent_fd);
> +}
[Severity: Medium]
Does this code leak the child cgroup and pollute the state for the inherit
subtest?
Because the child cgroup is not explicitly removed here (e.g., via
remove_cgroup()), the directory persists in the filesystem after the file
descriptor is closed.
When test_inherit() runs immediately afterward, its call to
create_and_get_cgroup() will re-open this existing cgroup instead of creating a
new one. This causes test_inherit() to silently bypass the intended
cgroup_bpf_inherit() testing path, and instead exercise the
cgroup_bpf_update_effective() path during the parent attachment.
[ ... ]
> +static void test_inherit(int parent_fd, struct bpf_tcp_ops *skel)
> +{
> + struct bpf_link *plink = NULL;
> + int child_fd = -1;
> +
> + plink = bpf_map__attach_cgroup_opts(skel->maps.tcp_ops1, parent_fd, NULL);
> + if (!ASSERT_OK_PTR(plink, "attach_parent"))
> + goto done;
> +
> + child_fd = create_and_get_cgroup(CGROUP_PATH "/child");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623175006.3136053-1-ameryhung@gmail.com?part=14
next prev parent reply other threads:[~2026-06-24 0:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 17:49 [PATCH bpf-next v2 00/15] bpf: A common way to attach struct_ops to a cgroup Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 01/15] bpf: Remove __rcu tagging in st_link->map Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 02/15] bpf: Make struct_ops tasks_rcu grace period optional Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 03/15] bpf: Add bpf_struct_ops accessor helpers Amery Hung
2026-06-23 21:40 ` sashiko-bot
2026-06-23 17:49 ` [PATCH bpf-next v2 04/15] bpf: Remove unnecessary prog_list_prog() check Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 05/15] bpf: Replace prog_list_prog() check with direct pl->prog and pl->link check Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 06/15] bpf: Add prog_list_init_item(), prog_list_replace_item(), and prog_list_id() Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 07/15] bpf: Move LSM trampoline unlink into bpf_cgroup_link_auto_detach() Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 08/15] bpf: Add a few bpf_cgroup_array_* helper functions Amery Hung
2026-06-23 22:25 ` sashiko-bot
2026-06-23 17:49 ` [PATCH bpf-next v2 09/15] bpf: Add infrastructure to support attaching struct_ops to cgroups Amery Hung
2026-06-23 22:53 ` sashiko-bot
2026-06-23 17:49 ` [PATCH bpf-next v2 10/15] bpf: Allow all struct_ops to use bpf_dynptr_from_skb() Amery Hung
2026-06-23 17:49 ` [PATCH bpf-next v2 11/15] bpf: tcp: Support selected sock_ops callbacks as struct_ops Amery Hung
2026-06-23 23:22 ` sashiko-bot
2026-06-23 17:50 ` [PATCH bpf-next v2 12/15] bpf: tcp: Support parse/len/write header option hooks in bpf_tcp_ops Amery Hung
2026-06-23 23:40 ` sashiko-bot
2026-06-23 17:50 ` [PATCH bpf-next v2 13/15] libbpf: Support attaching struct_ops to a cgroup Amery Hung
2026-06-23 23:53 ` sashiko-bot
2026-06-23 17:50 ` [PATCH bpf-next v2 14/15] selftests/bpf: Test " Amery Hung
2026-06-24 0:03 ` sashiko-bot [this message]
2026-06-23 17:50 ` [PATCH bpf-next v2 15/15] selftests/bpf: Add test for bpf_tcp_ops header option hooks Amery Hung
2026-06-24 0:14 ` sashiko-bot
[not found] ` <0e6fb8d7eca4b5494e08a2230056e333bdd814d97c16784b3e1f7687b3640990@mail.kernel.org>
2026-06-23 21:11 ` [PATCH bpf-next v2 00/15] bpf: A common way to attach struct_ops to a cgroup Amery Hung
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=20260624000312.AD6581F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ameryhung@gmail.com \
--cc=bpf@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.