OSDN Git Service

bpf: Annotate data races in bpf_local_storage
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Tue, 21 Feb 2023 20:06:42 +0000 (21:06 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 22 Feb 2023 20:49:34 +0000 (12:49 -0800)
commit0a09a2f933c73dc76ab0b72da6855f44342a8903
treebda3e74877477e36eeb46236cbaae764f91a62de
parentbf9bec4cb3a401a14c24a7ef937d3c26aff9ad60
bpf: Annotate data races in bpf_local_storage

There are a few cases where hlist_node is checked to be unhashed without
holding the lock protecting its modification. In this case, one must use
hlist_unhashed_lockless to avoid load tearing and KCSAN reports. Fix
this by using lockless variant in places not protected by the lock.

Since this is not prompted by any actual KCSAN reports but only from
code review, I have not included a fixes tag.

Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: KP Singh <kpsingh@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230221200646.2500777-4-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/bpf_local_storage.c