From: Viktor Malik <vmalik@redhat.com>
To: Eduard Zingerman <eddyz87@gmail.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: Fri, 27 Sep 2024 09:12:26 +0200 [thread overview]
Message-ID: <85a8ac47-c9b4-45ff-9905-8919316a365e@redhat.com> (raw)
In-Reply-To: <efa0ba9ce828010cd6fea1efa45b17c1b0800ace.camel@gmail.com>
On 9/27/24 03:37, Eduard Zingerman wrote:
> 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.
That's a great point, thanks. Let me remove the unbounded variants for
now, until we add the null-byte check to the verifier. The bounded
variants will still be useful to bpftrace so I'd love to have them added.
Viktor
>
> [...]
>
prev parent reply other threads:[~2024-09-27 7:12 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 ` [PATCH bpf-next v2 0/2] bpf: Add kfuncs for read-only string operations Eduard Zingerman
2024-09-27 7:12 ` Viktor Malik [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=85a8ac47-c9b4-45ff-9905-8919316a365e@redhat.com \
--to=vmalik@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--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=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