Message ID | 20200818162409.837005-1-yhs@fb.com |
---|---|
State | New |
Headers | show |
Series | bpf: two fixes for bpf task/task_file iterators | expand |
diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c index 885b14cab2c0..d6e1a141ea5c 100644 --- a/kernel/bpf/task_iter.c +++ b/kernel/bpf/task_iter.c @@ -31,8 +31,9 @@ static struct task_struct *task_seq_get_next(struct pid_namespace *ns, rcu_read_lock(); retry: - pid = idr_get_next(&ns->idr, tid); + pid = find_ge_pid(*tid, ns); if (pid) { + *tid = pid_nr_ns(pid, ns); task = get_pid_task(pid, PIDTYPE_PID); if (!task) { ++*tid;
Currently when traversing all tasks, the next tid is always increased by one. This may result in visiting the same task multiple times in a pid namespace. This patch fixed the issue by seting the next tid as pid_nr_ns(pid, ns) + 1, similar to funciton next_tgid(). Cc: Rik van Riel <riel@surriel.com> Signed-off-by: Yonghong Song <yhs@fb.com> --- kernel/bpf/task_iter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)