* [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage
@ 2020-09-16 20:44 Martin KaFai Lau
2020-09-17 22:15 ` Song Liu
2020-09-18 23:16 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Martin KaFai Lau @ 2020-09-16 20:44 UTC (permalink / raw)
To: bpf; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, netdev
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")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
kernel/bpf/bpf_local_storage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index ffa7d11fc2bd..5d3a7af9ba9b 100644
--- a/kernel/bpf/bpf_local_storage.c
+++ b/kernel/bpf/bpf_local_storage.c
@@ -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)
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage
2020-09-16 20:44 [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage Martin KaFai Lau
@ 2020-09-17 22:15 ` Song Liu
2020-09-18 23:16 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2020-09-17 22:15 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Kernel Team, Networking
On Thu, Sep 17, 2020 at 9:57 AM Martin KaFai Lau <kafai@fb.com> wrote:
>
> 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")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage
2020-09-16 20:44 [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage Martin KaFai Lau
2020-09-17 22:15 ` Song Liu
@ 2020-09-18 23:16 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-09-18 23:16 UTC (permalink / raw)
To: Martin KaFai Lau, bpf; +Cc: Alexei Starovoitov, kernel-team, netdev
On 9/16/20 10:44 PM, Martin KaFai Lau wrote:
> 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")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-18 23:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 20:44 [PATCH bpf-next] bpf: Use hlist_add_head_rcu when linking to local_storage Martin KaFai Lau
2020-09-17 22:15 ` Song Liu
2020-09-18 23:16 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).