Patch "bpf: Add KF_RCU flag to bpf_refcount_acquire_impl" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpf: Add KF_RCU flag to bpf_refcount_acquire_impl

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpf-add-kf_rcu-flag-to-bpf_refcount_acquire_impl.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 471695d031497bd6f13a01ed6a8a70cdda25b714
Author: Dave Marchevsky <davemarchevsky@xxxxxx>
Date:   Tue Nov 7 00:56:34 2023 -0800

    bpf: Add KF_RCU flag to bpf_refcount_acquire_impl
    
    [ Upstream commit 1500a5d9f49cb66906d3ea1c9158df25cc41dd40 ]
    
    Refcounted local kptrs are kptrs to user-defined types with a
    bpf_refcount field. Recent commits ([0], [1]) modified the lifetime of
    refcounted local kptrs such that the underlying memory is not reused
    until RCU grace period has elapsed.
    
    Separately, verification of bpf_refcount_acquire calls currently
    succeeds for MAYBE_NULL non-owning reference input, which is a problem
    as bpf_refcount_acquire_impl has no handling for this case.
    
    This patch takes advantage of aforementioned lifetime changes to tag
    bpf_refcount_acquire_impl kfunc KF_RCU, thereby preventing MAYBE_NULL
    input to the kfunc. The KF_RCU flag applies to all kfunc params; it's
    fine for it to apply to the void *meta__ign param as that's populated by
    the verifier and is tagged __ign regardless.
    
      [0]: commit 7e26cd12ad1c ("bpf: Use bpf_mem_free_rcu when
           bpf_obj_dropping refcounted nodes") is the actual change to
           allocation behaivor
      [1]: commit 0816b8c6bf7f ("bpf: Consider non-owning refs to refcounted
           nodes RCU protected") modified verifier understanding of
           refcounted local kptrs to match [0]'s changes
    
    Signed-off-by: Dave Marchevsky <davemarchevsky@xxxxxx>
    Fixes: 7c50b1cb76ac ("bpf: Add bpf_refcount_acquire kfunc")
    Link: https://lore.kernel.org/r/20231107085639.3016113-2-davemarchevsky@xxxxxx
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 56b0c1f678ee..6950f0461634 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2520,7 +2520,7 @@ BTF_ID_FLAGS(func, bpf_obj_new_impl, KF_ACQUIRE | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_percpu_obj_new_impl, KF_ACQUIRE | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_obj_drop_impl, KF_RELEASE)
 BTF_ID_FLAGS(func, bpf_percpu_obj_drop_impl, KF_RELEASE)
-BTF_ID_FLAGS(func, bpf_refcount_acquire_impl, KF_ACQUIRE | KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_refcount_acquire_impl, KF_ACQUIRE | KF_RET_NULL | KF_RCU)
 BTF_ID_FLAGS(func, bpf_list_push_front_impl)
 BTF_ID_FLAGS(func, bpf_list_push_back_impl)
 BTF_ID_FLAGS(func, bpf_list_pop_front, KF_ACQUIRE | KF_RET_NULL)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux