bpf: Fix an issue due to uninitialized bpf_iter_task
authorYafang Shao <laoar.shao@gmail.com>
Sat, 17 Feb 2024 11:41:51 +0000 (19:41 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 19 Feb 2024 11:28:15 +0000 (12:28 +0100)
commit5f2ae606cb5a90839a9be9d22388c4200f820e75
tree95d2c6a9b5d7acb4ea4d1581f15b7e5dc3aa480d
parent3f00e4a9c96f4488a924aff4e35b77c8eced897e
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: ac8148d957f5 ("bpf: bpf_iter_task_next: use next_task(kit->task) rather than next_task(kit->pos)")
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/bpf/20240217114152.1623-2-laoar.shao@gmail.com
kernel/bpf/task_iter.c