public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eduard Zingerman" <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 2/2] selftests/bpf: verify kallsyms entries for token-loaded subprograms
Date: Wed, 15 Apr 2026 01:21:05 +0000	[thread overview]
Message-ID: <20260415012106.5C63CC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260414-subprog-token-fix-v2-2-59146c31f6f1@gmail.com>

Sashiko AI review found 1 potential issue(s):
- [Medium] The test modifies global sysctls (`perf_event_paranoid` and `kptr_restrict`) while running in parallel, causing race conditions and potential host state leakage.
--

commit 9e0a167112286dfb5b44d5686732b8297533a10b
Author: Eduard Zingerman <eddyz87@gmail.com>

selftests/bpf: verify kallsyms entries for token-loaded subprograms

This commit adds a test to verify that both the main program and its global
subprogram appear in /proc/kallsyms when loaded using a user namespace BPF
token. It temporarily modifies global sysctl variables to allow reading
kallsym addresses.

> diff --git a/tools/testing/selftests/bpf/prog_tests/token.c b/tools/testing/selftests/bpf/prog_tests/token.c
> index b81dde283052e..89da527ed9304 100644
> --- a/tools/testing/selftests/bpf/prog_tests/token.c
> +++ b/tools/testing/selftests/bpf/prog_tests/token.c

[ ... ]

> @@ -1194,4 +1252,23 @@ void test_token(void)
>  
>  		subtest_userns(&opts, userns_bpf_token_info);
>  	}
> +	if (test__start_subtest("obj_priv_prog_kallsyms")) {
> +		char perf_paranoid_orig[32] = {};
> +		char kptr_restrict_orig[32] = {};
> +		struct bpffs_opts opts = {
> +			.cmds = bit(BPF_BTF_LOAD) | bit(BPF_PROG_LOAD),
> +			.progs = bit(BPF_PROG_TYPE_XDP),
> +			.attachs = ~0ULL,
> +		};
> +
> +		sysctl_set("/proc/sys/kernel/perf_event_paranoid", perf_paranoid_orig, "0");
> +		sysctl_set("/proc/sys/kernel/kptr_restrict", kptr_restrict_orig, "0");

The BPF selftest framework executes test_token() concurrently with other
tests because it lacks the serial_test_ prefix.

If another parallel test modifies or relies on these sysctls simultaneously,
can this create a race condition where the parallel test reads the
already-modified "0" as its original state? 

This could result in the host permanently retaining the lowered security
settings once the tests complete.

Should this test be renamed to serial_test_token() to prevent concurrent
modification of global system state?

> +
> +		subtest_userns(&opts, userns_obj_priv_prog_kallsyms);
> +
> +		if (perf_paranoid_orig[0])
> +			sysctl_set("/proc/sys/kernel/perf_event_paranoid", NULL, perf_paranoid_orig);
> +		if (kptr_restrict_orig[0])
> +			sysctl_set("/proc/sys/kernel/kptr_restrict", NULL, kptr_restrict_orig);
> +	}
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260414-subprog-token-fix-v2-0-59146c31f6f1@gmail.com?part=2

  reply	other threads:[~2026-04-15  1:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15  0:30 [PATCH bpf-next v2 0/2] bpf: copy BPF token from main program to subprograms Eduard Zingerman
2026-04-15  0:30 ` [PATCH bpf-next v2 1/2] " Eduard Zingerman
2026-04-15  1:08   ` sashiko-bot
2026-04-15 18:30     ` Eduard Zingerman
2026-04-15  0:30 ` [PATCH bpf-next v2 2/2] selftests/bpf: verify kallsyms entries for token-loaded subprograms Eduard Zingerman
2026-04-15  1:21   ` sashiko-bot [this message]
2026-04-15  5:55     ` Eduard Zingerman

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=20260415012106.5C63CC19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=sashiko@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