BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Longjun Tang" <lange_tang@163.com>, <ast@kernel.org>,
	<andrii@kernel.org>
Cc: <yonghong.song@linux.dev>, <jolsa@kernel.org>,
	<bpf@vger.kernel.org>, <tanglongjun@kylinos.cn>
Subject: Re: [PATCH bpf-next v2 0/5] bpf: add bpf_memcmp and bpf_strpbrk kfuncs
Date: Wed, 24 Jun 2026 14:01:41 -0700	[thread overview]
Message-ID: <DJHKZQ8DHCW5.QCBIXNEWDLEC@gmail.com> (raw)
In-Reply-To: <20260624093638.117062-1-lange_tang@163.com>

On Wed Jun 24, 2026 at 2:36 AM PDT, Longjun Tang wrote:
> From: Longjun Tang <tanglongjun@kylinos.cn>
>
> This series adds two new BPF kfuncs to kernel/bpf/helpers.c.
>
> === bpf_memcmp() ===
>
> BPF programs frequently need to compare raw binary buffers, such as:
> - MAC addresses (6 bytes) in XDP/TC for L2 filtering and forwarding;
> - UUIDs (16 bytes) and hash digests for allowlist/denylist policies;
>
> Currently there is no safe way to do this — bpf_strncmp (helper) stops
> at null bytes which corrupts binary data, and hand-rolled loops are
> fragile with the verifier (as evidenced by the local_memcmp() workaround
> in selftests/bpf/progs/dynptr_success.c). __builtin_memcmp may work in
> some cases but is not verifier-safe for arbitrary kernel memory.

Hand rolled loops were fragile in the past, but not any more.
With bpf_for() and may_goto/can_loop the loops can be large.
For MAC and UUIDs even old verifiers can deal just with with "bounded loop".

Sorry, but I don't see a human driven motivation in this patch.
Looks like AI flagged something and AI sloped a patch in response.

pw-bot: cr


      parent reply	other threads:[~2026-06-24 21:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24  9:36 [PATCH bpf-next v2 0/5] bpf: add bpf_memcmp and bpf_strpbrk kfuncs Longjun Tang
2026-06-24  9:36 ` [PATCH bpf-next v2 1/5] bpf: add bpf_memcmp kfunc Longjun Tang
2026-06-24  9:48   ` sashiko-bot
2026-06-24  9:36 ` [PATCH bpf-next v2 2/5] selftests/bpf: rename local bpf_memcmp to avoid conflict Longjun Tang
2026-06-24  9:36 ` [PATCH bpf-next v2 3/5] selftests/bpf: add tests for bpf_memcmp Longjun Tang
2026-06-24  9:36 ` [PATCH bpf-next v2 4/5] bpf: add bpf_strpbrk kfunc Longjun Tang
2026-06-24  9:49   ` sashiko-bot
2026-06-24  9:36 ` [PATCH bpf-next v2 5/5] selftests/bpf: add tests for bpf_strpbrk Longjun Tang
2026-06-24  9:48   ` sashiko-bot
2026-06-24 12:08   ` bot+bpf-ci
2026-06-24 21:01 ` Alexei Starovoitov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DJHKZQ8DHCW5.QCBIXNEWDLEC@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jolsa@kernel.org \
    --cc=lange_tang@163.com \
    --cc=tanglongjun@kylinos.cn \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox