Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>, bpf@vger.kernel.org
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 8/9] selftests/bpf: Verify iter link_create logs
Date: Sat, 14 Nov 2026 15:16:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-214682@kernel.org> (raw)
In-Reply-To: <20261114150610.84507-9-leon.hwang@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/bpf: swapped iter_info and iter_info_len subtest names
--

commit 05954811719a2e7df15c96088c216104e09ba282
Author: Leon Hwang <leon.hwang@linux.dev>

selftests/bpf: Verify iter link_create logs

This commit adds selftests verifying the error codes, log messages, and
reported log sizes for invalid bpf_link_create() iterator arguments and
programs.

> diff --git a/tools/testing/selftests/bpf/prog_tests/iter_link.c b/tools/testing/selftests/bpf/prog_tests/iter_link.c
> new file mode 100644
> index 0000000000000..623a84ba612d5
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/iter_link.c

[ ... ]

> +static void test_log_invalid_iter_info(void)
> +{
> +	unsigned char info[sizeof(union bpf_iter_link_info) + 1] = {};
> +	const char *msg = "Invalid iter_info_len.\n";
> +	struct bpf_iter_bpf_map *skel;
> +	struct bpf_link *link;
> +	char log_buf[128] = {};
> +	LIBBPF_OPTS(bpf_log_opts, log_opts,
> +		    .buf = log_buf,
> +		    .size = sizeof(log_buf),
> +		    .level = 1,
> +	);
> +	LIBBPF_OPTS(bpf_iter_attach_opts, opts,
> +		    .link_info = (union bpf_iter_link_info *)info,
> +		    .link_info_len = sizeof(info),
> +		    .log_opts = &log_opts,
> +	);
> +
> +	skel = bpf_iter_bpf_map__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "bpf_iter_bpf_map__open_and_load"))
> +		return;
> +
> +	info[sizeof(info) - 1] = 1;
> +	link = bpf_program__attach_iter(skel->progs.dump_bpf_map, &opts);
> +	if (!ASSERT_ERR_PTR(link, "bpf_program__attach_iter")) {
> +		bpf_link__destroy(link);
> +		goto out;
> +	}
> +
> +	ASSERT_EQ(libbpf_get_error(link), -E2BIG, "err");
> +	ASSERT_STREQ(log_buf, msg, "log_buf");
> +	ASSERT_EQ(log_opts.true_size, strlen(msg) + 1, "log_size");
> +
> +out:
> +	bpf_iter_bpf_map__destroy(skel);
> +}
> +
> +static void test_log_invalid_iter_info_len(void)
> +{
> +	const char *msg = "Invalid iter_info.\n";
> +	LIBBPF_OPTS(bpf_link_create_opts, opts,
> +		    .iter.info = (union bpf_iter_link_info *)1,
> +		    .iter.len = sizeof(union bpf_iter_link_info),
> +	);
> +
> +	test_iter_link_create_log(0, &opts, 0, -EFAULT, msg);
> +}
> +
> +static void test_log_invalid_prog(void)
> +{
> +	const char *msg = "The iter target does not support the bpf prog.\n";
> +	LIBBPF_OPTS(bpf_link_create_opts, opts);
> +
> +	test_iter_link_create_log(0, &opts, BPF_F_SLEEPABLE, -EINVAL, msg);
> +}
> +
> +void test_iter_link_log(void)
> +{
> +	if (test__start_subtest("invalid_target_fd"))
> +		test_log_invalid_target_fd();
> +	if (test__start_subtest("invalid_flags"))
> +		test_log_invalid_flags();
> +	if (test__start_subtest("iter_info_only"))
> +		test_log_iter_info_only();
> +	if (test__start_subtest("iter_info_len_only"))
> +		test_log_iter_info_len_only();
> +	if (test__start_subtest("invalid_iter_info"))
> +		test_log_invalid_iter_info();
> +	if (test__start_subtest("invalid_iter_info_len"))
> +		test_log_invalid_iter_info_len();

[Severity: Low]
Are the function and subtest names for test_log_invalid_iter_info() and
test_log_invalid_iter_info_len() swapped?

test_log_invalid_iter_info() passes an oversized link_info_len with a
non-zero trailing byte and checks for -E2BIG ("Invalid iter_info_len."),
whereas test_log_invalid_iter_info_len() passes a bad iter.info pointer
and checks for -EFAULT ("Invalid iter_info.").  If either subtest fails,
the reported subtest name will point to the opposite check.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261114150610.84507-1-leon.hwang@linux.dev?part=8

  reply	other threads:[~2026-11-14 15:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 15:06 [PATCH bpf-next v2 0/9] bpf: Add log support for tracing link_create Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 1/9] " Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 2/9] bpf: Add log support for tracing_multi link_create Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 3/9] bpf: Add log support for iter link_create Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 4/9] bpf: Add log support for cgroup prog link_create Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 5/9] libbpf: Add log_opts support for BPF_TRACE_ITER Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 6/9] selftests/bpf: Verify tracing link_create logs Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 7/9] selftests/bpf: Verify tracing_multi " Leon Hwang
2026-11-14 15:06 ` [PATCH bpf-next v2 8/9] selftests/bpf: Verify iter " Leon Hwang
2026-11-14 15:16   ` sashiko-bot [this message]
2026-11-14 15:06 ` [PATCH bpf-next v2 9/9] selftests/bpf: Verify cgroup prog " Leon Hwang

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=sashiko-outbox-214682@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-trace-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox