Skip to contentSkip to conversation

bpf: Use hlist_add_head_rcu when linking to local_storage

PATCH Applied Martin KaFai Lau 3 participants 3 messages Sep 17, 2020 – Sep 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 450af8d0f6be ("bpf: Split bpf_local_storage to bpf_sk_storage")
---
 kernel/bpf/bpf_local_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/bpf_local_storage.c +1 -1
index ffa7d11fc2bd..5d3a7af9ba9b 100644
@@ -159,7 +159,7 @@ void bpf_selem_link_storage_nolock(struct bpf_local_storage *local_storage,
 				   struct bpf_local_storage_elem *selem)
 {
 	RCU_INIT_POINTER(selem->local_storage, local_storage);
-	hlist_add_head(&selem->snode, &local_storage->list);
+	hlist_add_head_rcu(&selem->snode, &local_storage->list);
 }
 
 void bpf_selem_unlink_map(struct bpf_local_storage_elem *selem)
Signature · 1 line
2.24.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Martin KaFai Lau

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.

Quoted 4 lines

A separate fix has been provided to the bpf tree.

Fixes 450af8d0f6be ("bpf: Split bpf_local_storage to bpf_sk_storage")
maintainer Applied
#2 lore raw
In reply to Martin KaFai Lau
Quoted 9 lines · Martin KaFai Lau

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.

Quoted 4 lines

A separate fix has been provided to the bpf tree.

Fixes 450af8d0f6be ("bpf: Split bpf_local_storage to bpf_sk_storage")

Applied, thanks!