BPF List
 help / color / mirror / Atom feed
* [bpf-next v1 1/2] bpf: Fix iter/task tid filtering
@ 2024-10-15 18:27 Jordan Rome
  2024-10-15 18:27 ` [bpf-next v1 2/2] bpf: properly test " Jordan Rome
  2024-10-16 20:09 ` [bpf-next v1 1/2] bpf: Fix " Andrii Nakryiko
  0 siblings, 2 replies; 4+ messages in thread
From: Jordan Rome @ 2024-10-15 18:27 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Kernel Team

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>
---
 kernel/bpf/task_iter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
index 02aa9db8d796..5af9e130e500 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -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();
--
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-16 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 18:27 [bpf-next v1 1/2] bpf: Fix iter/task tid filtering Jordan Rome
2024-10-15 18:27 ` [bpf-next v1 2/2] bpf: properly test " Jordan Rome
2024-10-16 20:08   ` Andrii Nakryiko
2024-10-16 20:09 ` [bpf-next v1 1/2] bpf: Fix " Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox