Skip to content

KFunc bpf_crypto_ctx_acquire

v6.10

Acquire a reference to a BPF crypto context.

Definition

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

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)

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

Usage

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:

Example

see bpf_crypto_ctx_create for an example