]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Fix iter/task tid filtering
authorJordan Rome <linux@jordanrome.com>
Wed, 16 Oct 2024 21:00:47 +0000 (14:00 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 01:02:32 +0000 (02:02 +0100)
[ Upstream commit 9495a5b731fcaf580448a3438d63601c88367661 ]

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: f0d74c4da1f0 ("bpf: Parameterize task iterators.")
Signed-off-by: Jordan Rome <linux@jordanrome.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241016210048.1213935-1-linux@jordanrome.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/task_iter.c

index 02aa9db8d79616d3e0ebe62622a8738f41d34f28..5af9e130e500fa0a397760168c014b570ec8b260 100644 (file)
@@ -99,7 +99,7 @@ static struct task_struct *task_seq_get_next(struct bpf_iter_seq_task_common *co
                rcu_read_lock();
                pid = find_pid_ns(common->pid, common->ns);
                if (pid) {
-                       task = get_pid_task(pid, PIDTYPE_TGID);
+                       task = get_pid_task(pid, PIDTYPE_PID);
                        *tid = common->pid;
                }
                rcu_read_unlock();