title | description |
---|---|
KFunc 'bpf_task_acquire' |
This page documents the 'bpf_task_acquire' eBPF kfunc, including its defintion, usage, program types that can use it, and examples. |
Acquire a reference to a task.
A task acquired by this kfunc which is not stored in a map as a kptr, must be released by callingbpf_task_release()
.
p
: The task on which a reference is being acquired.
#!c struct task_struct *bpf_task_acquire(struct task_struct *p)
!!! note
This kfunc returns a pointer to a refcounted object. The verifier will then ensure that the pointer to the object
is eventually released using a release kfunc, or transferred to a map using a referenced kptr
(by invoking bpf_kptr_xchg
). If not, the verifier fails the
loading of the BPF program until no lingering references remain in all possible explored states of the program.
!!! note The pointer returned by the kfunc may be NULL. Hence, it forces the user to do a NULL check on the pointer returned from the kfunc before making use of it (dereferencing or passing to another helper).
!!! example "Docs could be improved" This part of the docs is incomplete, contributions are very welcome
The following program types can make use of this kfunc:
- BPF_PROG_TYPE_LSM
- BPF_PROG_TYPE_SCHED_CLS
- BPF_PROG_TYPE_STRUCT_OPS
- BPF_PROG_TYPE_TRACING
- BPF_PROG_TYPE_XDP
!!! example "Docs could be improved" This part of the docs is incomplete, contributions are very welcome