aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/task_ls_recursion.c
diff options
context:
space:
mode:
authorSong Liu <[email protected]>2021-02-25 23:43:15 +0000
committerAlexei Starovoitov <[email protected]>2021-02-26 19:51:48 +0000
commitbc235cdb423a2daed6f337676006a66557429cd1 (patch)
tree397fc9c1c0b454bfe2856b9f70cbf08e1467d396 /tools/testing/selftests/bpf/progs/task_ls_recursion.c
parentbpf: Enable task local storage for tracing programs (diff)
downloadkernel-bc235cdb423a2daed6f337676006a66557429cd1.tar.gz
kernel-bc235cdb423a2daed6f337676006a66557429cd1.zip
bpf: Prevent deadlock from recursive bpf_task_storage_[get|delete]
BPF helpers bpf_task_storage_[get|delete] could hold two locks: bpf_local_storage_map_bucket->lock and bpf_local_storage->lock. Calling these helpers from fentry/fexit programs on functions in bpf_*_storage.c may cause deadlock on either locks. Prevent such deadlock with a per cpu counter, bpf_task_storage_busy. We need this counter to be global, because the two locks here belong to two different objects: bpf_local_storage_map and bpf_local_storage. If we pick one of them as the owner of the counter, it is still possible to trigger deadlock on the other lock. For example, if bpf_local_storage_map owns the counters, it cannot prevent deadlock on bpf_local_storage->lock when two maps are used. Signed-off-by: Song Liu <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/progs/task_ls_recursion.c')
0 files changed, 0 insertions, 0 deletions