From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Viktor Malik <vmalik@redhat.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Eduard Zingerman <eddyz87@gmail.com>, bpf <bpf@vger.kernel.org>,
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 1/2] bpf: Add kfuncs for read-only string operations
Date: Thu, 27 Feb 2025 08:24:15 -0800 [thread overview]
Message-ID: <CAADnVQLOq835yg2przDwvNfPNiJf4BW2Pczbj_Bf7Lfy1JP2ag@mail.gmail.com> (raw)
In-Reply-To: <CAADnVQKJr_Gmf1SjTpmVLSWaPi=0irza365_Jb2-3kOKhKULdg@mail.gmail.com>
Viktor,
Are you still planning to work on string kfuncs ?
I think we more or less converged on requirements.
So only a small matter of programming is left ? :)
If you're busy with other things we can take over.
On Wed, Oct 9, 2024 at 7:03 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Thu, Oct 3, 2024 at 12:37 PM Viktor Malik <vmalik@redhat.com> wrote:
> >
> > Anyways, it seems to me that both the bounded and the unbounded versions
> > have their place. Would it be ok with you to open-code just the
> > unbounded ones and call in-kernel implementations for the bounded ones?
>
> Right. Open coding unbounded ones is not a lot of code.
> We can copy paste from arch/x86/boot/string.c and replace
> pointer deref with __get_kernel_nofault().
> No need to be fancy.
>
> The bounded ones should call into in-kernel bits that are
> optimized in asm.
>
> Documenting the difference in performance between bounded vs unbounded
> should be part of the patch.
>
> > Also, just out of curiosity, what are the ways to create/obtain strings
> > of unbounded length in BPF programs? Arguments of BTF-enabled program
> > types (like fentry)? Any other examples? Because IIUC, when you read
> > strings from kernel/userspace memory using bpf_probe_read_str, you
> > always need to specify the size.
>
> The main use case is argv/env processing in bpf-lsm programs.
> These strings are nul terminated and can be very large.
> Attackers use multi megabyte env vars to hide things.
>
> Folks push them into ringbuf and strstr() in user space as a workaround.
> Unbounded bpf_strstr() kfunc would be handy.
next prev parent reply other threads:[~2025-02-27 16:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 6:18 [PATCH bpf-next 0/2] bpf: Add kfuncs for read-only string operations Viktor Malik
2024-09-26 6:18 ` [PATCH bpf-next 1/2] " Viktor Malik
2024-09-30 22:00 ` Andrii Nakryiko
2024-10-01 11:26 ` Eduard Zingerman
2024-10-01 14:48 ` Alexei Starovoitov
2024-10-01 17:03 ` Andrii Nakryiko
2024-10-01 17:34 ` Alexei Starovoitov
2024-10-01 17:40 ` Andrii Nakryiko
2024-10-02 6:12 ` Viktor Malik
2024-10-02 16:55 ` Alexei Starovoitov
2024-10-03 4:51 ` Viktor Malik
2024-10-03 17:02 ` Alexei Starovoitov
2024-10-03 19:37 ` Viktor Malik
2024-10-10 2:03 ` Alexei Starovoitov
2025-02-27 16:24 ` Alexei Starovoitov [this message]
2025-02-27 16:36 ` Viktor Malik
2025-02-27 17:17 ` Alexei Starovoitov
2024-09-26 6:18 ` [PATCH bpf-next 2/2] selftests/bpf: Add tests for string kfuncs 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=CAADnVQLOq835yg2przDwvNfPNiJf4BW2Pczbj_Bf7Lfy1JP2ag@mail.gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.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=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;
as well as URLs for NNTP newsgroup(s).