Re: [PATCH bpf-next 1/2] bpf: add skcipher API support to TC/XDP programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26.10.2023 23:53, Alexei Starovoitov wrote:
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.

I was thinking about adding GFP_ATOMIC allocation option to
crypto_alloc_sync_skcipher, it's already implemented for cloning skcipher
object. Then the code can be reused for both sleepable (expect module loading)
and non-sleepable (fail if there is no crypto module loaded) variants without
any changes. But I can implement different allocators for different options.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux