mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
bpf: Allow local storage to be used from LSM programs
Adds support for both bpf_{sk, inode}_storage_{get, delete} to be used in LSM programs. These helpers are not used for tracing programs (currently) as their usage is tied to the life-cycle of the object and should only be used where the owning object won't be freed (when the owning object is passed as an argument to the LSM hook). Thus, they are safer to use in LSM hooks than tracing. Usage of local storage in tracing programs will probably follow a per function based whitelist approach. Since the UAPI helper signature for bpf_sk_storage expect a bpf_sock, it, leads to a compilation warning for LSM programs, it's also updated to accept a void * pointer instead. Signed-off-by: KP Singh <kpsingh@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200825182919.1118197-7-kpsingh@chromium.org
This commit is contained in:
committed by
Alexei Starovoitov
parent
8ea636848a
commit
30897832d8
@@ -2808,7 +2808,7 @@ union bpf_attr {
|
||||
*
|
||||
* **-ERANGE** if resulting value was out of range.
|
||||
*
|
||||
* void *bpf_sk_storage_get(struct bpf_map *map, struct bpf_sock *sk, void *value, u64 flags)
|
||||
* void *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags)
|
||||
* Description
|
||||
* Get a bpf-local-storage from a *sk*.
|
||||
*
|
||||
@@ -2824,6 +2824,9 @@ union bpf_attr {
|
||||
* "type". The bpf-local-storage "type" (i.e. the *map*) is
|
||||
* searched against all bpf-local-storages residing at *sk*.
|
||||
*
|
||||
* *sk* is a kernel **struct sock** pointer for LSM program.
|
||||
* *sk* is a **struct bpf_sock** pointer for other program types.
|
||||
*
|
||||
* An optional *flags* (**BPF_SK_STORAGE_GET_F_CREATE**) can be
|
||||
* used such that a new bpf-local-storage will be
|
||||
* created if one does not exist. *value* can be used
|
||||
@@ -2836,7 +2839,7 @@ union bpf_attr {
|
||||
* **NULL** if not found or there was an error in adding
|
||||
* a new bpf-local-storage.
|
||||
*
|
||||
* long bpf_sk_storage_delete(struct bpf_map *map, struct bpf_sock *sk)
|
||||
* long bpf_sk_storage_delete(struct bpf_map *map, void *sk)
|
||||
* Description
|
||||
* Delete a bpf-local-storage from a *sk*.
|
||||
* Return
|
||||
|
Reference in New Issue
Block a user