-
Notifications
You must be signed in to change notification settings - Fork 159
bpf/verifier: Expand the usage scenarios of bpf_kptr_xchg #10934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bpf-next_base
Are you sure you want to change the base?
Conversation
|
Upstream branch: 6b95cc5 |
cecc6f5 to
68193d8
Compare
|
Upstream branch: d95d76a |
b5a7e6e to
c76b432
Compare
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: AI-authorship-score: low |
|
Forwarding comment 3838760901 via email |
68193d8 to
f129d4b
Compare
|
Upstream branch: f941479 |
c76b432 to
680ff73
Compare
f129d4b to
8d76c66
Compare
|
Upstream branch: f11f7cf |
680ff73 to
9f5c0f2
Compare
8d76c66 to
eec9a8d
Compare
For the following scenario:
struct tree_node {
struct bpf_rb_node node;
struct request __kptr *req;
u64 key;
};
struct bpf_rb_root tree_root __contains(tree_node, node);
struct bpf_spin_lock tree_lock;
If we need to traverse all nodes in the rbtree, retrieve the __kptr
pointer from each node, and read kernel data from the referenced
object, using bpf_kptr_xchg appears unavoidable.
This patch skips the BPF verifier checks for bpf_kptr_xchg when
called while holding a lock.
Signed-off-by: Chengkaitao Com <[email protected]>
…is set When traversing an rbtree using bpf_rbtree_left/right, if bpf_kptr_xchg is used to access the __kptr pointer contained in a node, it currently requires first removing the node with bpf_rbtree_remove and clearing the NON_OWN_REF flag, then re-adding the node to the original rbtree with bpf_rbtree_add after usage. This process significantly degrades rbtree traversal performance. The patch enables accessing __kptr pointers with the NON_OWN_REF flag set while holding the lock, eliminating the need for this remove-read-readd sequence. Signed-off-by: Chengkaitao Com <[email protected]> Signed-off-by: Feng Yang <[email protected]>
1. Allow using bpf_kptr_xchg while holding a lock. 2. When the rb_node contains a __kptr pointer, we do not need to perform a remove-read-add operation. This patch implements the following workflow: 1. Construct a rbtree with 16 elements. 2. Traverse the rbtree, locate the kptr pointer in the target node, and read the content pointed to by the pointer. 3. Remove all nodes from the rbtree. Signed-off-by: Chengkaitao Com <[email protected]> Signed-off-by: Feng Yang <[email protected]>
|
Upstream branch: b28dac3 |
9f5c0f2 to
01fd567
Compare
Pull request for series with
subject: bpf/verifier: Expand the usage scenarios of bpf_kptr_xchg
version: 5
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1050033