From: Daniel Borkmann <daniel@iogearbox.net>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>, ast@kernel.org
Cc: memxor@gmail.com, eddyz87@gmail.com, info@starlabs.sg,
bpf@vger.kernel.org
Subject: Re: [PATCH bpf 2/4] bpf: Require CAP_PERFMON for kfuncs reading memory
Date: Thu, 10 Sep 2026 17:53:35 +0200 [thread overview]
Message-ID: <7598df39-e4b3-434c-b4ff-67efb8b6d8e9@iogearbox.net> (raw)
In-Reply-To: <DLBR1FDW787I.2PNNYKF8PP4MY@gmail.com>
On 9/10/26 5:41 PM, Alexei Starovoitov wrote:
> On Thu Sep 10, 2026 at 7:21 AM PDT, Daniel Borkmann wrote:
>> Mark fault-safe probe reading kfuncs as KF_PERFMON, similarly as we do for
>> the old-style BPF helper equivalents. bpf_rdonly_cast() is included in this
>> list as well as it returns PTR_TO_MEM | MEM_RDONLY | PTR_UNTRUSTED for an
>> unchecked object and is using fault-safe BPF_PROBE_MEM.
>>
>> Note that only the void form of bpf_rdonly_cast() produced a register that
>> was readable without CAP_PERFMON. For a struct type id the kfunc returns
>> PTR_TO_BTF_ID | PTR_UNTRUSTED, whose dereference has always been gated in
>> check_ptr_to_btf_access(). The flag is not conditional on the type id, so
>> for the latter it only moves the rejection from the dereference to the call
>> itself, which is the better place to report it anyway.
>>
>> The bpf_stream_vprintk() and bpf_stream_print_stack() kfuncs are marked
>> as well. The former ends up in the same bpf_bprintf_prepare() as the
>> bpf_snprintf() helper, where %pks, %pus and %pI4 read through a program-
>> supplied address and %pB resolves one into a symbol. The latter walks the
>> stack and prints each instruction pointer via %pS.
>>
>> Fixes: 4665415975b0 ("bpf: Add bits iterator")
>> Fixes: 65ab5ac4df01 ("bpf: Add bpf_copy_from_user_str kfunc")
>> Fixes: f0f8a5b58f78 ("bpf: Add bpf_copy_from_user_task_str() kfunc")
>> Fixes: a498ee7576de ("bpf: Implement dynptr copy kfuncs")
>> Fixes: f2362a57aeff ("bpf: allow void* cast using bpf_rdonly_cast()")
>> Fixes: e91370550f1f ("bpf: Add kfuncs for read-only string operations")
>> Fixes: 5ab154f1463a ("bpf: Introduce BPF standard streams")
>> Fixes: 19559e844184 ("bpf: add bpf_strcasecmp kfunc")
>> Fixes: b5b693f73589 ("bpf: add bpf_strcasestr,bpf_strncasestr kfuncs")
>> Fixes: 1dc669646762 ("bpf: add bpf_strncasecmp kfunc")
>> Fixes: 63328bb23f26 ("bpf: Add bpf_stream_print_stack stack dumping kfunc")
>
> Let's drop this Fixes list altogether, since it will only cause
> headaches to stable folks. We don't need to backport this everywhere.
> Not really an issue.
> CAP_BPF alone can leak memory via HW speculation,
> so this patch isn't strictly necessary, but I don't mind closing the hole
> since AI keeps reporting it.
>
> Also pls add bpf_get_kmem_cache() as AI suggested.
Ack, will address and also the one from your other email.
Thanks,
Daniel
next prev parent reply other threads:[~2026-09-10 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 14:21 [PATCH bpf 1/4] bpf: Add KF_PERFMON kfunc flag Daniel Borkmann
2026-09-10 14:21 ` [PATCH bpf 2/4] bpf: Require CAP_PERFMON for kfuncs reading memory Daniel Borkmann
2026-09-10 15:10 ` bot+bpf-ci
2026-09-10 15:41 ` Alexei Starovoitov
2026-09-10 15:53 ` Daniel Borkmann [this message]
2026-09-10 14:21 ` [PATCH bpf 3/4] bpf: Require CAP_PERFMON for untrusted read-only memory reads Daniel Borkmann
2026-09-10 15:42 ` Alexei Starovoitov
2026-09-10 14:21 ` [PATCH bpf 4/4] selftests/bpf: Add tests for the KF_PERFMON gates Daniel Borkmann
2026-09-10 15:03 ` [PATCH bpf 1/4] bpf: Add KF_PERFMON kfunc flag Mykyta Yatsenko
2026-09-10 15:14 ` Kumar Kartikeya Dwivedi
2026-09-10 15:21 ` Mykyta Yatsenko
2026-09-10 15:10 ` 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=7598df39-e4b3-434c-b4ff-67efb8b6d8e9@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=info@starlabs.sg \
--cc=memxor@gmail.com \
/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