32
32
*
33
33
* Different map implementations will rely on rcu in map methods
34
34
* lookup/update/delete, therefore eBPF programs must run under rcu lock
35
- * if program is allowed to access maps, so check rcu_read_lock_held in
36
- * all three functions.
35
+ * if program is allowed to access maps, so check rcu_read_lock_held() or
36
+ * rcu_read_lock_trace_held() in all three functions.
37
37
*/
38
38
BPF_CALL_2 (bpf_map_lookup_elem , struct bpf_map * , map , void * , key )
39
39
{
40
- WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ());
40
+ WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () &&
41
+ !rcu_read_lock_bh_held ());
41
42
return (unsigned long ) map -> ops -> map_lookup_elem (map , key );
42
43
}
43
44
@@ -53,7 +54,8 @@ const struct bpf_func_proto bpf_map_lookup_elem_proto = {
53
54
BPF_CALL_4 (bpf_map_update_elem , struct bpf_map * , map , void * , key ,
54
55
void * , value , u64 , flags )
55
56
{
56
- WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ());
57
+ WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () &&
58
+ !rcu_read_lock_bh_held ());
57
59
return map -> ops -> map_update_elem (map , key , value , flags );
58
60
}
59
61
@@ -70,7 +72,8 @@ const struct bpf_func_proto bpf_map_update_elem_proto = {
70
72
71
73
BPF_CALL_2 (bpf_map_delete_elem , struct bpf_map * , map , void * , key )
72
74
{
73
- WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_bh_held ());
75
+ WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held () &&
76
+ !rcu_read_lock_bh_held ());
74
77
return map -> ops -> map_delete_elem (map , key );
75
78
}
76
79
0 commit comments