All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 07/10] selftests/bpf: Test arena binding by libbpf
Date: Mon, 12 Oct 2026 13:44:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-168206@kernel.org> (raw)
In-Reply-To: <20261012133711.4030594-8-memxor@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] selftests/bpf: uninitialized stack memory read in assert_prog_map() on test failure
--

commit 2eeeb2c231d34a25c0bfb615692f8a717edbdc53
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>

selftests/bpf: Test arena binding by libbpf

This commit introduces a test to ensure libbpf correctly binds an arena
to all programs in an object, even if they don't explicitly refer to it.
It also relocates programs that were previously expected to fail without
an arena to a new object without an arena map to preserve their negative
tests.

> diff --git a/tools/testing/selftests/bpf/prog_tests/test_struct_ops_arena.c b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_arena.c
> index 1a7fe0d6c5a4c..a45b360b4c65d 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_struct_ops_arena.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_struct_ops_arena.c
[ ... ]
> @@ -144,6 +145,50 @@ static void arena_member(void)
>  	struct_ops_arena_member__destroy(skel);
>  }
>  
> +/* @prog_fd lists exactly one map, the one with @map_id. */
> +static void assert_prog_map(int prog_fd, __u32 map_id, const char *name)
> +{
> +	__u32 map_ids[2], len = sizeof(struct bpf_prog_info);
> +	struct bpf_prog_info info = {
> +		.nr_map_ids = ARRAY_SIZE(map_ids),
> +		.map_ids = ptr_to_u64(map_ids),
> +	};
> +	int err;
> +
> +	err = bpf_prog_get_info_by_fd(prog_fd, &info, &len);
> +	if (!ASSERT_OK(err, name))
> +		return;
> +	ASSERT_EQ(info.nr_map_ids, 1, name);
> +	ASSERT_EQ(map_ids[0], map_id, name);

[Severity: Low]
Does this read uninitialized stack memory on test failure?

If bpf_prog_get_info_by_fd() successfully returns but the program has 0 maps,
it will set info.nr_map_ids = 0 and leave the map_ids array unwritten.
Since ASSERT_EQ() does not abort the test on failure, execution will continue
to the next assertion, which evaluates map_ids[0].

Could we return early if info.nr_map_ids != 1, or initialize the map_ids
array to zero?

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012133711.4030594-1-memxor@gmail.com?part=7

  reply	other threads:[~2026-10-12 13:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 13:36 [PATCH bpf-next v1 00/10] Fix some arena paper cuts Kumar Kartikeya Dwivedi
2026-10-12 13:36 ` [PATCH bpf-next v1 01/10] compiler_types: Add __arena and __nullable BTF type tag qualifiers Kumar Kartikeya Dwivedi
2026-10-12 13:36 ` [PATCH bpf-next v1 02/10] bpf: Recognize __nullable on pointer members of kernel structs Kumar Kartikeya Dwivedi
2026-10-12 13:54   ` sashiko-bot
2026-10-12 13:37 ` [PATCH bpf-next v1 03/10] bpf: Turn loads of __arena pointer members into arena pointers Kumar Kartikeya Dwivedi
2026-10-12 14:00   ` sashiko-bot
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 04/10] selftests/bpf: Test __nullable pointer members Kumar Kartikeya Dwivedi
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 05/10] selftests/bpf: Test __arena " Kumar Kartikeya Dwivedi
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 06/10] libbpf: Bind the arena of an object to every program in it Kumar Kartikeya Dwivedi
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 07/10] selftests/bpf: Test arena binding by libbpf Kumar Kartikeya Dwivedi
2026-10-12 13:44   ` sashiko-bot [this message]
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 08/10] bpf: Set up the arena base only in functions that use it Kumar Kartikeya Dwivedi
2026-10-12 14:27   ` bot+bpf-ci
2026-10-12 13:37 ` [PATCH bpf-next v1 09/10] libbpf: Render the arena type tag with its address space Kumar Kartikeya Dwivedi
2026-10-12 13:37 ` [PATCH bpf-next v1 10/10] selftests/bpf: Test the address space rendering of the arena type tag Kumar Kartikeya Dwivedi

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-168206@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@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 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.