mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: abhishekkhade69@gmail.com,bpf@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,memxor@gmail.com,linux-kernel@vger.kernel.org,abhishekkhade69@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [RFC PATCH bpf-next 1/2] bpf: Add bpf_memmem and bpf_dynptr_memmem kfuncs
Date: Sun, 22 Nov 2026 11:26:11 +0000 (UTC)	[thread overview]
Message-ID: <4fc370f55464ca8cca8c568368199863d477c38b332f9b78da00e821ec91070f@mail.kernel.org> (raw)
In-Reply-To: <20261122103838.244974-2-abhishekkhade69@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1524 bytes --]

> bpf: Add bpf_memmem and bpf_dynptr_memmem kfuncs

TL;DR: Nits only: possibly unreachable needle_sz and !ptr checks in the memmem
kfuncs; the empty-needle branch returns offset 0, contradicting the
documentation.

> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c

[ ... ]

> +static void *__bpf_memmem(const void *haystack, size_t haystack_sz,
> +			  const void *needle, size_t needle_sz)
> +{
> +	const char *h = haystack;
> +	const char *n = needle;
> +	const char *end;
> +
> +	if (needle_sz == 0)
> +		return (void *)haystack;
> +	if (needle_sz > haystack_sz)
> +		return NULL;

this isn't a bug, but are these two needle_sz checks in __bpf_memmem()
reachable?

Both bpf_memmem() and bpf_dynptr_memmem() already reject needle__sz == 0
and needle__sz > haystack size with -EINVAL before calling it.  The
empty-needle branch here also returns a match at offset 0, which is the
opposite of what the kfunc documentation says.

[ ... ]

> +	if (!ptr || !ptr->data || !needle || needle__sz == 0)
> +		return -EINVAL;

Similarly, can !ptr be true in bpf_dynptr_memmem(), given that the verifier
requires an initialized dynptr argument?  The neighbouring dynptr kfuncs
such as bpf_dynptr_slice() only test ptr->data.


---
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

  reply	other threads:[~2026-11-22 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 10:38 [RFC PATCH bpf-next 0/2] " Abhishek Khade
2026-11-22 10:38 ` [RFC PATCH bpf-next 1/2] " Abhishek Khade
2026-11-22 11:26   ` bot+bpf-ci [this message]
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

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=4fc370f55464ca8cca8c568368199863d477c38b332f9b78da00e821ec91070f@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=abhishekkhade69@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --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

all inboxes | Powered by JetHome®