Skip to content

Commit 5f2ae60

Browse files
laoarborkmann
authored andcommitted
bpf: Fix an issue due to uninitialized bpf_iter_task
Failure to initialize it->pos, coupled with the presence of an invalid value in the flags variable, can lead to it->pos referencing an invalid task, potentially resulting in a kernel panic. To mitigate this risk, it's crucial to ensure proper initialization of it->pos to NULL. Fixes: ac8148d ("bpf: bpf_iter_task_next: use next_task(kit->task) rather than next_task(kit->pos)") Signed-off-by: Yafang Shao <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 3f00e4a commit 5f2ae60

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/bpf/task_iter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ __bpf_kfunc int bpf_iter_task_new(struct bpf_iter_task *it,
978978
BUILD_BUG_ON(__alignof__(struct bpf_iter_task_kern) !=
979979
__alignof__(struct bpf_iter_task));
980980

981+
kit->pos = NULL;
982+
981983
switch (flags) {
982984
case BPF_TASK_ITER_ALL_THREADS:
983985
case BPF_TASK_ITER_ALL_PROCS:

0 commit comments

Comments
 (0)