On Fri, 28 Feb 2025 at 21:42, Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Fri, 2025-02-28 at 08:28 -0800, Kumar Kartikeya Dwivedi wrote: > > The verifier currently does not permit global subprog calls when a lock > > is held, preemption is disabled, or when IRQs are disabled. This is > > because we don't know whether the global subprog calls sleepable > > functions or not. > > > > In case of locks, there's an additional reason: functions called by the > > global subprog may hold additional locks etc. The verifier won't know > > while verifying the global subprog whether it was called in context > > where a spin lock is already held by the program. > > > > Perform summarization of the sleepable nature of a global subprog just > > like changes_pkt_data and then allow calls to global subprogs for > > non-sleepable ones from atomic context. > > > > While making this change, I noticed that RCU read sections had no > > protection against sleepable global subprog calls, include it in the > > checks and fix this while we're at it. > > > > Care needs to be taken to not allow global subprog calls when regular > > bpf_spin_lock is held. When resilient spin locks is held, we want to > > potentially have this check relaxed, but not for now. > > > > Tests are included in the next patch to handle all special conditions. > > > > Fixes: 9bb00b2895cb ("bpf: Add kfunc bpf_rcu_read_lock/unlock()") > > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> > > --- > > I think this change also has to deal with freplace for sleepable > sub-programs, e.g. see verifier.c:bpf_check_attach_target(), > part dealing with `tgt_changes_pkt_data`. > > Other than that the logic seems ok. Ah, good catch. Let me fix that and add a test to check it. > > [...] >