BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxim Skokov" <skokovmaksimevg@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 2/2] selftests/bpf: Check that bpftool map dump fails for socket storage
Date: Fri, 25 Sep 2026 16:29:14 +0000	[thread overview]
Message-ID: <20260925162915.2CB261F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925162031.27259-3-skokovmaksimevg@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: missing unlink of pinned map causes permanent test failure
--

commit 602b2c7f146f62e2714d566e5a1fb9912bee7425
Author: Maxim Skokov <skokovmaksimevg@gmail.com>

selftests/bpf: Check that bpftool map dump fails for socket storage

This commit adds a test to verify that bpftool fails to dump a socket
storage map. It creates a map, attaches storage to a socket, pins it,
and checks various output formats.

> diff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c
> new file mode 100644
> index 0000000000000..0a0fa8926b239
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c
> @@ -0,0 +1,88 @@
[ ... ]
> +void test_bpftool_map_dump(void)
> +{
> +	int map_fd, sk_fd = -1, value = 42, ret;
> +	char output[1024] = {};
> +
> +	map_fd = create_sk_storage_map();
> +	if (map_fd < 0)
> +		return;
> +
> +	sk_fd = socket(AF_INET, SOCK_STREAM, 0);
> +	if (!ASSERT_OK_FD(sk_fd, "socket"))
> +		goto out;
> +	if (!ASSERT_OK(bpf_map_update_elem(map_fd, &sk_fd, &value, BPF_NOEXIST),
> +		       "add socket storage"))
> +		goto out;
> +	if (!ASSERT_OK(bpf_obj_pin(map_fd, PIN_PATH), "pin map"))
> +		goto out;

[Severity: Medium]
Looking at test_bpftool_map_dump() in
tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c, will this cause a
permanent test failure on subsequent runs if the pin operation fails, or if the
test is interrupted early?

If bpf_obj_pin fails and we jump to the out label, the test skips over the
unlink cleanup. The map then remains pinned, which means the next run will
encounter EEXIST when it tries to pin the map again.

[ ... ]
> +	ASSERT_HAS_SUBSTR(output, "can't dump sk_storage map",
> +			  "plain dump explains why on stderr");
> +
> +	unlink(PIN_PATH);
> +out:
> +	if (sk_fd >= 0)
> +		close(sk_fd);
> +	close(map_fd);
> +}

[Severity: Medium]
Since the out label is positioned after unlink(PIN_PATH), the cleanup is
bypassed on failure paths.

Should the unlink be moved after the out label so the cleanup is always
executed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925162031.27259-1-skokovmaksimevg@gmail.com?part=2

  reply	other threads:[~2026-09-25 16:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 16:20 [PATCH bpf-next v2 0/2] bpftool: Fail map dump for maps that can't be iterated Maxim Skokov
2026-09-25 16:20 ` [PATCH bpf-next v2 1/2] " Maxim Skokov
2026-09-25 19:24   ` Quentin Monnet
2026-09-26  1:44     ` Tianyi Chen
2026-09-25 16:20 ` [PATCH bpf-next v2 2/2] selftests/bpf: Check that bpftool map dump fails for socket storage Maxim Skokov
2026-09-25 16:29   ` sashiko-bot [this message]
2026-09-25 19:32     ` Maxim Skokov

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=20260925162915.2CB261F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=skokovmaksimevg@gmail.com \
    /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