Re: [RFC PATCH bpf-next 2/2] selftests/bpf: Add selftests for bpf_memmem and bpf_dynptr_memmem kfuncs

From: bot+bpf-ci

Date: Sun Nov 22 2026 - 06:26:16 EST


> selftests/bpf: Add selftests for bpf_memmem and bpf_dynptr_memmem kfuncs

TL;DR: Nit only, in the memmem selftests: the (void *) casts in the
bpf_dynptr_from_mem() calls may be unnecessary, since the arrays aren't const
and other callers omit them.

> diff --git a/tools/testing/selftests/bpf/progs/memmem_kfunc.c b/tools/testing/selftests/bpf/progs/memmem_kfunc.c
> new file mode 100644
> index 000000000000..8abd06e9758d
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/memmem_kfunc.c

[ ... ]

> +SEC("syscall")
> +__success __retval(7)
> +int test_dynptr_memmem_embedded_null(void *ctx)
> +{
> + struct bpf_dynptr ptr;
> +
> + bpf_dynptr_from_mem((void *)bin_data, sizeof(bin_data), 0, &ptr);
> + return bpf_dynptr_memmem(&ptr, needle_null, sizeof(needle_null), 0);
> +}

this isn't a bug, but are the (void *) casts needed in the
bpf_dynptr_from_mem() calls?

bin_data, needle_start and oversized_buf are not const, so they convert to
void * implicitly. The bpf_memmem() calls earlier in this file pass the
same arrays without a cast, and dynptr_success.c passes map_val directly.

Dropping the casts would match those callers.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45015018001