Skip to content

Commit 7361c86

Browse files
puranjaymohanAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix list_del() in arena list
The __list_del fuction doesn't set the previous node's next pointer to the next node of the node to be deleted. It just updates the local variable and not the actual pointer in the previous node. The test was passing up till now because the bpf code is doing bpf_free() after list_del and therfore reading head->first from the userspace will read all zeroes. But after arena_list_del() is finished, head->first should point to NULL; Signed-off-by: Puranjay Mohan <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent b74938a commit 7361c86

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tools/testing/selftests/bpf/bpf_arena_list.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ static inline void list_add_head(arena_list_node_t *n, arena_list_head_t *h)
6464

6565
static inline void __list_del(arena_list_node_t *n)
6666
{
67-
arena_list_node_t *next = n->next, *tmp;
67+
arena_list_node_t *next = n->next;
6868
arena_list_node_t * __arena *pprev = n->pprev;
6969

7070
cast_user(next);
7171
cast_kern(pprev);
72-
tmp = *pprev;
73-
cast_kern(tmp);
74-
WRITE_ONCE(tmp, next);
72+
WRITE_ONCE(*pprev, next);
7573
if (next) {
7674
cast_user(pprev);
7775
cast_kern(next);

0 commit comments

Comments
 (0)