BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Viktor Malik <vmalik@redhat.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	 Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH bpf-next v2 0/2] bpf: Add kfuncs for read-only string operations
Date: Thu, 26 Sep 2024 18:37:07 -0700	[thread overview]
Message-ID: <efa0ba9ce828010cd6fea1efa45b17c1b0800ace.camel@gmail.com> (raw)
In-Reply-To: <cover.1727335530.git.vmalik@redhat.com>

On Thu, 2024-09-26 at 09:29 +0200, Viktor Malik wrote:
> Kernel contains highly optimised implementation of traditional string
> operations. Expose them as kfuncs to allow BPF programs leverage the
> kernel implementation instead of needing to reimplement the operations.
> 
> These will be very helpful to bpftrace as it now needs to implement all
> the string operations in LLVM IR.

Note that existing string related helpers take a pointer to a string
and it's maximal length, namely:
- bpf_strtol
- bpf_strtoul
- bpf_snprintf_btf
- bpf_strncmp

The unbounded variants that are being exposed in this patch-set
(like strcmp) are only safe to use if string is guaranteed to be null terminated.
Verifier does not check this property at the moment (idk how easy/hard
such analysis might be).

I'd suggest not to expose unbounded variants of string functions.

[...]


  parent reply	other threads:[~2024-09-27  1:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26  7:29 [PATCH bpf-next v2 0/2] bpf: Add kfuncs for read-only string operations Viktor Malik
2024-09-26  7:29 ` [PATCH bpf-next v2 1/2] " Viktor Malik
2024-09-26  7:29 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add tests for string kfuncs Viktor Malik
2024-09-27  1:57   ` Eduard Zingerman
2024-09-27  7:20     ` Viktor Malik
2024-09-27  1:37 ` Eduard Zingerman [this message]
2024-09-27  7:12   ` [PATCH bpf-next v2 0/2] bpf: Add kfuncs for read-only string operations Viktor Malik

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=efa0ba9ce828010cd6fea1efa45b17c1b0800ace.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=vmalik@redhat.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