BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrii Nakryiko" <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 2/2] selftests/bpf: Add linked_externs test for externs in allocated sections
Date: Sat, 26 Sep 2026 00:08:42 +0000	[thread overview]
Message-ID: <20260926000843.134841F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260926000243.2830819-2-andrii@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/bpf: unhandled mkstemp() failure in test_relink()
--

commit e2fcaeeb4be58f57f9657902a9e400bc15e30412
Author: Andrii Nakryiko <andrii@kernel.org>

selftests/bpf: Add linked_externs test for externs in allocated sections

This commit adds a selftest to verify that the BPF linker correctly handles
extern variables in allocated sections (like arena and maps). It tests the
behavior both via the BPF skeleton and by directly driving the libbpf linker
API.

> diff --git a/tools/testing/selftests/bpf/prog_tests/linked_externs.c b/tools/testing/selftests/bpf/prog_tests/linked_externs.c
> new file mode 100644
> index 0000000000000..29358c82dc356
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/linked_externs.c
[ ... ]
> +/* link in1 on its own first, then link the result with in2 */
> +static void test_relink(const char *in1, const char *in2, const char *sec_name)
> +{
> +	char out1[] = "/tmp/linked_externs.XXXXXX", out2[] = "/tmp/linked_externs.XXXXXX";
> +	const struct btf_var_secinfo *vi;
> +	struct bpf_object *obj = NULL;
> +	const struct btf_type *t;
> +	struct btf *btf;
> +	int i, id, n;
> +
> +	close(mkstemp(out1));
> +	close(mkstemp(out2));

[Severity: Medium]
What happens if mkstemp() fails here?

If it returns -1, it will be passed directly to close() which will just fail,
but the template strings will remain undefined (typically unmodified). The
test would then continue using the predictable string
"/tmp/linked_externs.XXXXXX" for file operations.

Could this cause collisions with other concurrent test runs or leave leftover
predictable files in /tmp?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260926000243.2830819-1-andrii@kernel.org?part=2

  reply	other threads:[~2026-09-26  0:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26  0:02 [PATCH v2 bpf-next 1/2] libbpf: Fix static linking of externs placed in allocated sections Andrii Nakryiko
2026-09-26  0:02 ` [PATCH v2 bpf-next 2/2] selftests/bpf: Add linked_externs test for externs " Andrii Nakryiko
2026-09-26  0:08   ` sashiko-bot [this message]
2026-09-26  0:50   ` bot+bpf-ci
2026-09-28 21:52   ` Vineet Gupta
2026-09-28 21:52     ` Vineet Gupta
2026-09-26  0:50 ` [PATCH v2 bpf-next 1/2] libbpf: Fix static linking of externs placed " bot+bpf-ci
2026-09-26  8:51 ` Alexei Starovoitov

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=20260926000843.134841F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=andrii@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox