Skip to content

KFunc bpf_crypto_ctx_acquire


Acquire a reference to a BPF crypto context.


Acquires a reference to a BPF crypto context. The context returned by this function must either be embedded in a map as a kptr, or freed with bpf_crypto_ctx_release.

ctx: The BPF crypto context being acquired. The ctx must be a trusted pointer.


Returns ctx on success, or NULL if a reference could not be acquired.

struct bpf_crypto_ctx *bpf_crypto_ctx_acquire(struct bpf_crypto_ctx *ctx)


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.


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).


This kfunc can be used to acquire a reference to a BPF crypto context that was previously created using bpf_crypto_ctx_create. This allows you to add the same context to multiple values in the same map or to multiple maps.

Program types

The following program types can make use of this kfunc:


see bpf_crypto_ctx_create for an example