mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/2] bpf: Add bpf_memmem and bpf_dynptr_memmem kfuncs
@ 2026-11-22 10:38 Abhishek Khade
  2026-11-22 10:38 ` [RFC PATCH bpf-next 1/2] " Abhishek Khade
  2026-11-22 10:38 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Add selftests for " Abhishek Khade
  0 siblings, 2 replies; 5+ messages in thread
From: Abhishek Khade @ 2026-11-22 10:38 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, andrii, memxor, linux-kernel, Abhishek Khade

This patch series introduces two new BPF kfuncs for binary-safe
substring searching in raw memory and dynamic pointers:
- bpf_memmem(): Searches for a binary needle within a flat memory buffer.
- bpf_dynptr_memmem(): Searches for a binary needle within a BPF dynptr.

Both kfuncs utilize a two-tier search strategy (memchr() for initial byte
matching followed by memcmp()) and enforce maximum buffer length
boundaries (BPF_MEMMEM_MAX_LEN). Selftests covering boundary conditions,
embedded null bytes, and dynptr integration are included.

Abhishek Khade (2):
  bpf: Add bpf_memmem and bpf_dynptr_memmem kfuncs
  selftests/bpf: Add selftests for bpf_memmem and bpf_dynptr_memmem
    kfuncs

 kernel/bpf/helpers.c                          | 115 ++++++++
 .../selftests/bpf/prog_tests/memmem_kfunc.c   |   9 +
 .../selftests/bpf/progs/memmem_kfunc.c        | 259 ++++++++++++++++++
 3 files changed, 383 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/memmem_kfunc.c
 create mode 100644 tools/testing/selftests/bpf/progs/memmem_kfunc.c

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-22 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 10:38 [RFC PATCH bpf-next 0/2] bpf: Add bpf_memmem and bpf_dynptr_memmem kfuncs Abhishek Khade
2026-11-22 10:38 ` [RFC PATCH bpf-next 1/2] " Abhishek Khade
2026-11-22 11:26   ` bot+bpf-ci
2026-11-22 10:38 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Add selftests for " Abhishek Khade
2026-11-22 11:26   ` bot+bpf-ci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®