Commit 9495a5b7 authored by Jordan Rome's avatar Jordan Rome Committed by Andrii Nakryiko

bpf: Fix iter/task tid filtering

In userspace, you can add a tid filter by setting
the "task.tid" field for "bpf_iter_link_info".
However, `get_pid_task` when called for the
`BPF_TASK_ITER_TID` type should have been using
`PIDTYPE_PID` (tid) instead of `PIDTYPE_TGID` (pid).

Fixes: f0d74c4d ("bpf: Parameterize task iterators.")
Signed-off-by: default avatarJordan Rome <linux@jordanrome.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241016210048.1213935-1-linux@jordanrome.com
parent e59db062
...@@ -99,7 +99,7 @@ static struct task_struct *task_seq_get_next(struct bpf_iter_seq_task_common *co ...@@ -99,7 +99,7 @@ static struct task_struct *task_seq_get_next(struct bpf_iter_seq_task_common *co
rcu_read_lock(); rcu_read_lock();
pid = find_pid_ns(common->pid, common->ns); pid = find_pid_ns(common->pid, common->ns);
if (pid) { if (pid) {
task = get_pid_task(pid, PIDTYPE_TGID); task = get_pid_task(pid, PIDTYPE_PID);
*tid = common->pid; *tid = common->pid;
} }
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment