bpf_crypto_ctx_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_crypto_ctx_create(9)

okay so this is a page from the Kernel API Manual β€” yes, the kernel has manpages too, we stay educated πŸ’– β€” and it's all about bpf_crypto_ctx_create, the little function that spawns a mutable BPF crypto context for you. mutable!! crypto!! bestie we are SO back πŸ”₯


✨ NAME ✨

bpf_crypto_ctx_create β€” creates a mutable BPF crypto context. that's it, that's the whole name, and honestly it ate πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

__bpf_kfunc struct bpf_crypto_ctx * bpf_crypto_ctx_create (const struct
bpf_crypto_params *params , u32 params__sz , int *err );

it's giving "long signature, tiny name" energy. she's a __bpf_kfunc, she returns a struct bpf_crypto_ctx *, and she takes three things. let's get into it πŸ¦‹


🌸 ARGUMENTS 🌸

  • params β€” pointer to struct bpf_crypto_params, which holds literally all the details you need to initialise the crypto context. the whole blueprint. the vibe check for your cipher πŸ’…
  • params__sz β€” the size of struct bpf_crypto_params as used by the BPF program. (ngl the original page spells it "steuct" and "usef" β€” iconic typo moment, we keep it real 🫢, but it's struct and used, iykyk)
  • err β€” an integer where the error code gets stored whenever NULL comes back. so like, if it flops, this is where the receipts live 😭

🌈 DESCRIPTION 🌈

so what does she do? she allocates a crypto context that a BPF program can use, acquire, and release. main character energy honestly πŸ’œ

the context she returns has exactly two acceptable fates, no third option, periodt:

  • it gets embedded in a map as a kptr, or
  • it gets freed with bpf_crypto_ctx_release πŸ’€
⭐ fr fr do not just leave it lying around β€” those are the options.

and because crypto API functions use GFP_KERNEL allocations, this function can only be used in sleepable BPF programs. no cap, that's a hard requirement, not a suggestion 🧚

bpf_crypto_ctx_create allocates memory for the crypto context, and it may return NULL if no memory is available. lowkey devastating but that's what err is for πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

go read the whole friend group, they're all connected πŸ’–


and that's the page!! this one lives at ./kernel/bpf (the directory, not a person, sadly), it's dated October 2026 ⭐ β€” yes, the future, we're ahead of schedule β€” and it's page bpf_crypto_ctx_create(9) of the Kernel API Manual. slay, go create some contexts responsibly πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from