Re: [PATCH bpf-next 0/2] bpf: Track overlapping RCU protection
"Kumar Kartikeya Dwivedi" <[email protected]>
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On Thu Aug 6, 2026 at 11:13 AM CEST, Kumar Kartikeya Dwivedi wrote: > On Thu Aug 6, 2026 at 1:39 AM CEST, Ning Ding wrote: >> Preemption-disabled and IRQ-disabled regions provide RCU protection, but >> the verifier does not account for them. Current implementation can invalidate >> a task kptr while another RCU source remains active, or keep it valid >> after the final source ends. >> >> Track these regions and invalidate RCU-protected pointers only after the >> last protection ends. Add task kptr tests for overlapping protection and >> final-exit rejection. >> >> This follows review of the applied spin-unlock fix series [1]. >> >> Tested in QEMU/KVM: >> ./test_progs -t task_kfunc >> ./test_progs -t preempt_lock >> ./test_progs -t irq >> > > Overall, looks good. There are various failures in CI, so you might need to > update or adjust existing selftests. > > Make sure to include selftest changes for _existing_ tests within the kernel > commit making changes, so as to preserve bisection. Your extra tests should > still go in a separate commit. > > Also, do we need that was_in_rcu_cs logic for bpf_spin_lock(). Would it be > possible to drop it and do it the same way you've done it for other cases? > If that makes sense, I would fold that cleanup in the first patch as well. > > https://patchwork.kernel.org/project/netdevbpf/patch/[email protected] > > pw-bot: cr > I think from cursory look, the reason is that we forced any MEM_RCU pointer to be invalidated before, even when program wasn't sleepable, which does not happen now. The failing test used a non-sleepable program. So making it sleepable should preserve the failure case. In some ways, this is probably an improvement over current behavior. >> [1] https://lore.kernel.org/r/[email protected] >> >> Ning Ding (2): >> bpf: Account for preempt and IRQ state in RCU protection >> selftests/bpf: Test overlapping RCU protection >> >> kernel/bpf/verifier.c | 13 +- >> .../selftests/bpf/prog_tests/task_kfunc.c | 6 + >> .../selftests/bpf/progs/task_kfunc_common.h | 2 + >> .../selftests/bpf/progs/task_kfunc_failure.c | 49 ++++++ >> .../selftests/bpf/progs/task_kfunc_success.c | 147 ++++++++++++++++++ >> 5 files changed, 214 insertions(+), 3 deletions(-) >> >> >> base-commit: 11c1e836710dcba03e50454a4eedfdbaf8d3050e