Skip to content

Commit

Permalink
bpf: Implement task local storage
Browse files Browse the repository at this point in the history
Similar to bpf_local_storage for sockets and inodes add local storage
for task_struct.

The life-cycle of storage is managed with the life-cycle of the
task_struct.  i.e. the storage is destroyed along with the owning task
with a callback to the bpf_task_storage_free from the task_free LSM
hook.

The BPF LSM allocates an __rcu pointer to the bpf_local_storage in
the security blob which are now stackable and can co-exist with other
LSMs.

The userspace map operations can be done by using a pid fd as a key
passed to the lookup, update and delete operations.

Signed-off-by: KP Singh <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Song Liu <[email protected]>
Acked-by: Martin KaFai Lau <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
sinkap authored and Alexei Starovoitov committed Nov 6, 2020
1 parent 9e7a4d9 commit 4cf1bc1
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 1 deletion.
23 changes: 23 additions & 0 deletions include/linux/bpf_lsm.h
1 change: 1 addition & 0 deletions include/linux/bpf_types.h
39 changes: 39 additions & 0 deletions include/uapi/linux/bpf.h
1 change: 1 addition & 0 deletions kernel/bpf/Makefile
4 changes: 4 additions & 0 deletions kernel/bpf/bpf_lsm.c
315 changes: 315 additions & 0 deletions kernel/bpf/bpf_task_storage.c
3 changes: 2 additions & 1 deletion kernel/bpf/syscall.c
10 changes: 10 additions & 0 deletions kernel/bpf/verifier.c
2 changes: 2 additions & 0 deletions security/bpf/hooks.c
39 changes: 39 additions & 0 deletions tools/include/uapi/linux/bpf.h

0 comments on commit 4cf1bc1

Please sign in to comment.