On Thu, Feb 16, 2023 at 5:55 AM Hou Tao <houtao@xxxxxxxxxxxxxxx> wrote: > > Beside BPF_REUSE_AFTER_RCU_GP, is BPF_FREE_AFTER_RCU_GP a feasible solution ? The idea is for bpf_mem_free to wait normal RCU GP before adding the elements back to the free list and free the elem to global kernel memory only after both rcu and rcu_tasks_trace GPs as it's doing now. > Its downside is that it will enforce sleep-able program to use > bpf_rcu_read_{lock,unlock}() to access these returned pointers ? sleepable can access elems without kptrs/spin_locks even when not using rcu_read_lock, since it's safe, but there is uaf. Some progs might be fine with it. When sleepable needs to avoid uaf they will use bpf_rcu_read_lock.