On Wed, Oct 25, 2023 at 6:59 PM Vadim Fedorenko <vadfed@xxxxxxxx> wrote: > > +__bpf_kfunc struct bpf_crypto_skcipher_ctx * > +bpf_crypto_skcipher_ctx_create(const struct bpf_dynptr_kern *algo, const struct bpf_dynptr_kern *key, > + int *err) > +{ > + struct bpf_crypto_skcipher_ctx *ctx; > + > + if (__bpf_dynptr_size(algo) > CRYPTO_MAX_ALG_NAME) { > + *err = -EINVAL; > + return NULL; > + } > + > + if (!crypto_has_skcipher(algo->data, CRYPTO_ALG_TYPE_SKCIPHER, CRYPTO_ALG_TYPE_MASK)) { > + *err = -EOPNOTSUPP; > + return NULL; > + } > + > + ctx = bpf_mem_cache_alloc(&bpf_crypto_ctx_ma); Since this kfunc is sleepable, just kmalloc(GFP_KERNEL) here. No need to use bpf_mem_alloc.