• Dave Marchevsky's avatar
    bpf: Use bpf_mem_free_rcu when bpf_obj_dropping non-refcounted nodes · 649924b7
    Dave Marchevsky authored
    The use of bpf_mem_free_rcu to free refcounted local kptrs was added
    in commit 7e26cd12 ("bpf: Use bpf_mem_free_rcu when
    bpf_obj_dropping refcounted nodes"). In the cover letter for the
    series containing that patch [0] I commented:
    
        Perhaps it makes sense to move to mem_free_rcu for _all_
        non-owning refs in the future, not just refcounted. This might
        allow custom non-owning ref lifetime + invalidation logic to be
        entirely subsumed by MEM_RCU handling. IMO this needs a bit more
        thought and should be tackled outside of a fix series, so it's not
        attempted here.
    
    It's time to start moving in the "non-owning refs have MEM_RCU
    lifetime" direction. As mentioned in that comment, using
    bpf_mem_free_rcu for all local kptrs - not just refcounted - is
    necessarily the first step towards that goal. This patch does so.
    
    After this patch the memory pointed to by all local kptrs will not be
    reused until RCU grace period elapses. The verifier's understanding of
    non-owning ref validity and the clobbering logic it uses to enforce
    that understanding are not changed here, that'll happen gradually in
    future work, including further patches in the series.
    
      [0]: https://lore.kernel.org/all/20230821193311.3290257-1-davemarchevsky@fb.com/Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
    Link: https://lore.kernel.org/r/20231107085639.3016113-4-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    649924b7
helpers.c 69.8 KB