Skip to content

Commit 97b859b

Browse files
ameryhungMartin KaFai Lau
authored andcommitted
selftests/bpf: Fix outdated test on storage->smap
bpf_local_storage_free() already does not rely on local_storage->smap since switching to kmalloc_nolock(). As local_storage->smap is removed, fix the outdated test by dropping the local_storage->smap check. Keep the second map in task local storage map test to test that multiple elements can be added to the storage similar to sk storage test. Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20260205222916.1788211-18-ameryhung@gmail.com
1 parent cdce7b0 commit 97b859b

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

tools/testing/selftests/bpf/progs/local_storage.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ SEC("lsm/inode_unlink")
6262
int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim)
6363
{
6464
__u32 pid = bpf_get_current_pid_tgid() >> 32;
65-
struct bpf_local_storage *local_storage;
6665
struct local_storage *storage;
6766
struct task_struct *task;
6867
bool is_self_unlink;
@@ -88,15 +87,10 @@ int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim)
8887
if (!storage || storage->value)
8988
return 0;
9089

91-
if (bpf_task_storage_delete(&task_storage_map, task))
90+
if (bpf_task_storage_delete(&task_storage_map2, task))
9291
return 0;
9392

94-
/* Ensure that the task_storage_map is disconnected from the storage.
95-
* The storage memory should not be freed back to the
96-
* bpf_mem_alloc.
97-
*/
98-
local_storage = task->bpf_storage;
99-
if (!local_storage || local_storage->smap)
93+
if (bpf_task_storage_delete(&task_storage_map, task))
10094
return 0;
10195

10296
task_storage_result = 0;
@@ -164,18 +158,9 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address,
164158
if (bpf_sk_storage_delete(&sk_storage_map2, sk))
165159
return 0;
166160

167-
storage = bpf_sk_storage_get(&sk_storage_map2, sk, 0,
168-
BPF_LOCAL_STORAGE_GET_F_CREATE);
169-
if (!storage)
170-
return 0;
171-
172161
if (bpf_sk_storage_delete(&sk_storage_map, sk))
173162
return 0;
174163

175-
/* Ensure that the sk_storage_map is disconnected from the storage. */
176-
if (!sk->sk_bpf_storage || sk->sk_bpf_storage->smap)
177-
return 0;
178-
179164
sk_storage_result = 0;
180165
return 0;
181166
}

0 commit comments

Comments
 (0)