diff options
| author | Hou Tao <[email protected]> | 2023-02-15 08:21:32 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2023-02-15 23:40:06 +0000 |
| commit | f88da2d46cc9a19b0c233285339659cae36c5d9a (patch) | |
| tree | c36bec94b00c337da6266687758715ec9eaa0f92 /tools/testing/selftests/bpf/progs/htab_reuse.c | |
| parent | bpf: Zeroing allocated object from slab in bpf memory allocator (diff) | |
| download | kernel-f88da2d46cc9a19b0c233285339659cae36c5d9a.tar.gz kernel-f88da2d46cc9a19b0c233285339659cae36c5d9a.zip | |
selftests/bpf: Add test case for element reuse in htab map
The reinitialization of spin-lock in map value after immediate reuse may
corrupt lookup with BPF_F_LOCK flag and result in hard lock-up, so add
one test case to demonstrate the problem.
Signed-off-by: Hou Tao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/htab_reuse.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/htab_reuse.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/htab_reuse.c b/tools/testing/selftests/bpf/progs/htab_reuse.c new file mode 100644 index 000000000000..7f7368cb3095 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/htab_reuse.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2023. Huawei Technologies Co., Ltd */ +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +char _license[] SEC("license") = "GPL"; + +struct htab_val { + struct bpf_spin_lock lock; + unsigned int data; +}; + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(max_entries, 64); + __type(key, unsigned int); + __type(value, struct htab_val); + __uint(map_flags, BPF_F_NO_PREALLOC); +} htab SEC(".maps"); |
