Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: bpf: crypto: use NULL instead of 0-sized dynptr

Adjust selftests to use nullable option for state and IV arg.

Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
Link: https://lore.kernel.org/r/20240613211817.1551967-4-vadfed@meta.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Vadim Fedorenko and committed by
Alexei Starovoitov
9363dc8d 65d6d61d

+4 -12
+4 -12
tools/testing/selftests/bpf/progs/crypto_sanity.c
··· 89 89 { 90 90 struct __crypto_ctx_value *v; 91 91 struct bpf_crypto_ctx *ctx; 92 - struct bpf_dynptr psrc, pdst, iv; 92 + struct bpf_dynptr psrc, pdst; 93 93 int err; 94 94 95 95 err = skb_dynptr_validate(skb, &psrc); ··· 114 114 * production code, a percpu map should be used to store the result. 115 115 */ 116 116 bpf_dynptr_from_mem(dst, sizeof(dst), 0, &pdst); 117 - /* iv dynptr has to be initialized with 0 size, but proper memory region 118 - * has to be provided anyway 119 - */ 120 - bpf_dynptr_from_mem(dst, 0, 0, &iv); 121 117 122 - status = bpf_crypto_decrypt(ctx, &psrc, &pdst, &iv); 118 + status = bpf_crypto_decrypt(ctx, &psrc, &pdst, NULL); 123 119 124 120 return TC_ACT_SHOT; 125 121 } ··· 125 129 { 126 130 struct __crypto_ctx_value *v; 127 131 struct bpf_crypto_ctx *ctx; 128 - struct bpf_dynptr psrc, pdst, iv; 132 + struct bpf_dynptr psrc, pdst; 129 133 int err; 130 134 131 135 status = 0; ··· 152 156 * production code, a percpu map should be used to store the result. 153 157 */ 154 158 bpf_dynptr_from_mem(dst, sizeof(dst), 0, &pdst); 155 - /* iv dynptr has to be initialized with 0 size, but proper memory region 156 - * has to be provided anyway 157 - */ 158 - bpf_dynptr_from_mem(dst, 0, 0, &iv); 159 159 160 - status = bpf_crypto_encrypt(ctx, &psrc, &pdst, &iv); 160 + status = bpf_crypto_encrypt(ctx, &psrc, &pdst, NULL); 161 161 162 162 return TC_ACT_SHOT; 163 163 }