Skip to content

Add kfunc for doing pid -> task lookup

David Vernet bpf lkml 1 version Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Add bpf_task_from_pid() kfunckernel/bpf/helpers.c+20 -00 repliesApplied
2/2selftests/bpf: Add selftests for bpf_task_from_pid()tools/testing/selftests/bpf/prog_tests/task_kfunc.c tools/testing/selftests/bpf/progs/task_kfunc_common.h tools/testing/selftests/bpf/progs/task_kfunc_failure.c +1 more+91 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/2] Add kfunc for doing pid -> task lookup

A series of prior patches added support for storing struct task_struct * objects as kptrs. This patch set proposes extending this with another kfunc called bpf_task_from_pid() which performs a lookup of a task from its pid, from the root pid namespace idr.

This allows BPF programs that don't have a kptr to a task, to instead perform a lookup by pid. This will be useful for programs that are tracking pids and want, e.g., to do a lookup to find task->comm.

David Vernet (2):
bpf: Add bpf_task_from_pid() kfunc selftests/bpf: Add selftests for bpf_task_from_pid()

 kernel/bpf/helpers.c                          | 20 +++++
 .../selftests/bpf/prog_tests/task_kfunc.c     |  3 +
 .../selftests/bpf/progs/task_kfunc_common.h   |  1 +
 .../selftests/bpf/progs/task_kfunc_success.c  | 73 +++++++++++++++++++
 4 files changed, 97 insertions(+)
Signature · 1 line
2.38.1