From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Emil Tsalapatis <emil@etsalapatis.com>,
Nicholas Carlini <npc@anthropic.com>,
kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v2 2/2] selftests/bpf: Test global subprog callback contexts
Date: Fri, 11 Sep 2026 13:20:22 -0700 [thread overview]
Message-ID: <ed7fb81ef39f8e21bce6fb79698f5fbb6998159e.camel@gmail.com> (raw)
In-Reply-To: <20260905051224.2325381-3-memxor@gmail.com>
On Sat, 2026-09-05 at 07:12 +0200, Kumar Kartikeya Dwivedi wrote:
> Exercise global subprogram verification from workqueue and task-work
> callbacks. Both callback types can run in a sleepable context even when the
> containing program is not sleepable, so an unprotected callback must not let
> the global subprogram use implicit RCU protection inherited from the program.
>
> Add negative cases which load an RCU-protected task kptr in a global
> subprogram reached from each callback type. The tests fail on an unfixed
> kernel because the programs are incorrectly accepted.
>
> Also cover a workqueue callback protected by an explicit RCU read-side
> critical section. Finally, call the same harmless global subprogram directly
> from the main program and from an unprotected callback. This requires both
> non-sleepable and sleepable verification roots and proves that global calls
> from callbacks are not rejected wholesale.
>
> Keep the harmless global opaque to LLVM with barrier() so both call sites
__weak is another useful trick for such things.
> remain in the generated BPF object and the positive case cannot pass
> vacuously. Have workqueue callbacks return zero explicitly after calling a
> global subprogram, as required by their callback contract, instead of relying
> on interprocedural return-value optimization.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
...
> @@ -179,3 +285,29 @@ int task_work_sleepable_prog(void *ctx)
> bpf_task_work_schedule_resume(task, &val->tw, &task_work_map, task_work_cb);
> return 0;
> }
> +
> +static int task_work_global_rcu_cb(struct bpf_map *map, void *key, void *value)
> +{
> + return wq_global_acquire();
> +}
> +
> +SEC("fentry/bpf_fentry_test1")
> +__failure __msg("R1 must be a rcu pointer")
> +int task_work_global_rcu_prog(void *ctx)
> +{
> + struct task_work_elem *val;
> + struct task_struct *task;
> + int key = 0;
> +
> + val = bpf_map_lookup_elem(&task_work_map, &key);
> + if (!val)
> + return 0;
> +
> + task = bpf_get_current_task_btf();
> + if (!task)
> + return 0;
> +
> + bpf_task_work_schedule_resume(task, &val->tw, &task_work_map,
> + task_work_global_rcu_cb);
> + return 0;
> +}
I think this test is redundant.
prev parent reply other threads:[~2026-09-11 20:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 5:12 [PATCH bpf-next v2 0/2] Fix global subprog verification context Kumar Kartikeya Dwivedi
2026-09-05 5:12 ` [PATCH bpf-next v2 1/2] bpf: Verify global subprogs in each sleepability context Kumar Kartikeya Dwivedi
2026-09-05 5:32 ` sashiko-bot
2026-09-05 5:40 ` Kumar Kartikeya Dwivedi
2026-09-05 6:05 ` bot+bpf-ci
2026-09-05 6:13 ` Kumar Kartikeya Dwivedi
2026-09-05 22:39 ` Alexei Starovoitov
2026-09-11 19:12 ` Eduard Zingerman
2026-09-05 5:12 ` [PATCH bpf-next v2 2/2] selftests/bpf: Test global subprog callback contexts Kumar Kartikeya Dwivedi
2026-09-05 6:05 ` bot+bpf-ci
2026-09-11 20:20 ` Eduard Zingerman [this message]
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=ed7fb81ef39f8e21bce6fb79698f5fbb6998159e.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=memxor@gmail.com \
--cc=npc@anthropic.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