Skip to content

Commit 70b9711

Browse files
iamkafaiborkmann
authored andcommitted
bpf: Use hlist_add_head_rcu when linking to local_storage
The local_storage->list will be traversed by rcu reader in parallel. Thus, hlist_add_head_rcu() is needed in bpf_selem_link_storage_nolock(). This patch fixes it. This part of the code has recently been refactored in bpf-next and this patch makes changes to the new file "bpf_local_storage.c". Instead of using the original offending commit in the Fixes tag, the commit that created the file "bpf_local_storage.c" is used. A separate fix has been provided to the bpf tree. Fixes: 450af8d ("bpf: Split bpf_local_storage to bpf_sk_storage") Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f55f4c3 commit 70b9711

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/bpf_local_storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void bpf_selem_link_storage_nolock(struct bpf_local_storage *local_storage,
159159
struct bpf_local_storage_elem *selem)
160160
{
161161
RCU_INIT_POINTER(selem->local_storage, local_storage);
162-
hlist_add_head(&selem->snode, &local_storage->list);
162+
hlist_add_head_rcu(&selem->snode, &local_storage->list);
163163
}
164164

165165
void bpf_selem_unlink_map(struct bpf_local_storage_elem *selem)

0 commit comments

Comments
 (0)