hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/kernel/bpf/bpf_local_storage.c
....@@ -48,9 +48,19 @@
4848 return map->ops->map_owner_storage_ptr(owner);
4949 }
5050
51
+static bool selem_linked_to_storage_lockless(const struct bpf_local_storage_elem *selem)
52
+{
53
+ return !hlist_unhashed_lockless(&selem->snode);
54
+}
55
+
5156 static bool selem_linked_to_storage(const struct bpf_local_storage_elem *selem)
5257 {
5358 return !hlist_unhashed(&selem->snode);
59
+}
60
+
61
+static bool selem_linked_to_map_lockless(const struct bpf_local_storage_elem *selem)
62
+{
63
+ return !hlist_unhashed_lockless(&selem->map_node);
5464 }
5565
5666 static bool selem_linked_to_map(const struct bpf_local_storage_elem *selem)
....@@ -140,7 +150,7 @@
140150 struct bpf_local_storage *local_storage;
141151 bool free_local_storage = false;
142152
143
- if (unlikely(!selem_linked_to_storage(selem)))
153
+ if (unlikely(!selem_linked_to_storage_lockless(selem)))
144154 /* selem has already been unlinked from sk */
145155 return;
146156
....@@ -167,7 +177,7 @@
167177 struct bpf_local_storage_map *smap;
168178 struct bpf_local_storage_map_bucket *b;
169179
170
- if (unlikely(!selem_linked_to_map(selem)))
180
+ if (unlikely(!selem_linked_to_map_lockless(selem)))
171181 /* selem has already be unlinked from smap */
172182 return;
173183
....@@ -365,7 +375,7 @@
365375 err = check_flags(old_sdata, map_flags);
366376 if (err)
367377 return ERR_PTR(err);
368
- if (old_sdata && selem_linked_to_storage(SELEM(old_sdata))) {
378
+ if (old_sdata && selem_linked_to_storage_lockless(SELEM(old_sdata))) {
369379 copy_map_value_locked(&smap->map, old_sdata->data,
370380 value, false);
371381 return old_sdata;