diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2021-12-29 17:54:41 -0800 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2021-12-29 17:54:41 -0800 |
| commit | 1705c62e300550e8cfac0d9d1c3869fb860f3162 (patch) | |
| tree | 7f6f598f052e2dd7c07e9aae27c455e061fb06e2 /include/linux | |
| parent | 3ccdcee28415c4226de05438b4d89eb5514edf73 (diff) | |
| parent | 0ae6eff2978ee118ce2b536090af0682db13bb83 (diff) | |
Merge branch 'Sleepable local storage'
KP Singh says:
====================
Local storage is currently unusable in sleepable helpers. One of the
important use cases of local_storage is to attach security (or
performance) contextual information to kernel objects in LSM / tracing
programs to be used later in the life-cyle of the object.
Sometimes this context can only be gathered from sleepable programs
(because it needs accesing __user pointers or helpers like
bpf_ima_inode_hash). Allowing local storage to be used from sleepable
programs allows such context to be managed with the benefits of
local_storage.
# v2 -> v3
* Fixed some RCU issues pointed by Martin
* Added Martin's ack
# v1 -> v2
* Generalize RCU checks (will send a separate patch for updating
non local storage code where this can be used).
* Add missing RCU lock checks from v1
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/bpf_local_storage.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/bpf_local_storage.h b/include/linux/bpf_local_storage.h index a2b625960ffe..37b3906af8b1 100644 --- a/include/linux/bpf_local_storage.h +++ b/include/linux/bpf_local_storage.h @@ -17,6 +17,9 @@ #define BPF_LOCAL_STORAGE_CACHE_SIZE 16 +#define bpf_rcu_lock_held() \ + (rcu_read_lock_held() || rcu_read_lock_trace_held() || \ + rcu_read_lock_bh_held()) struct bpf_local_storage_map_bucket { struct hlist_head list; raw_spinlock_t lock; @@ -162,4 +165,6 @@ struct bpf_local_storage_data * bpf_local_storage_update(void *owner, struct bpf_local_storage_map *smap, void *value, u64 map_flags); +void bpf_local_storage_free_rcu(struct rcu_head *rcu); + #endif /* _BPF_LOCAL_STORAGE_H */ |
