From: Varun R Mallya <varunrmallya@gmail.com>
To: andrii@kernel.org, alan.maguire@oracle.com
Cc: ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, varunrmallya@gmail.com
Subject: [RFC PATCH bpf-next 0/1] Upgrading uprobe and kprobe to their `multi` counterparts.
Date: Thu, 12 Feb 2026 20:50:12 +0530 [thread overview]
Message-ID: <20260212152013.17351-1-varunrmallya@gmail.com> (raw)
This RFC patch explores auto-upgrading standard uprobes to use the
multi-uprobe infrastructure when supported by the underlying kernel.
Background:
The BPF token concept allows privileged operations inside non-privileged
user namespaces. However, attaching standard uprobes and kprobes
currently relies on the perf_event_open() syscall, which is not BPF
token-aware. Multi-uprobes and multi-kprobes bypass
perf_event_open() entirely, attaching via the bpf() syscall instead,
making them compatible with BPF tokens.
To bridge this gap, the goal is to switch SEC("uprobe") and
SEC("kprobe") to use multi-uprobe/kprobe under the hood. To maintain
backward compatibility for cases where singular uprobes are explicitly
desired, this patch also introduces SEC("uprobe.single") and
SEC("kprobe.single").
Current Implementation:
The decision to upgrade is made at BPF program load time in
`bpf_object_init_progs()`. If the kernel supports FEAT_UPROBE_MULTI_LINK,
we intercept programs with section names matching "u[ret]probe" and change
their `expected_attach_type` to BPF_TRACE_UPROBE_MULTI.
During attachment, `attach_uprobe` checks this expected type and
routes the attachment to `bpf_program__attach_uprobe_multi` accordingly.
I am currently hitting an issue with selftests, and I would appreciate
some guidance before proceeding to implement this for kprobes and fix it
for uprobes.
Selftests that rely on auto-attachment pass. However, tests that bypass
auto-attach and manually call `bpf_program__attach_uprobe_opts()` are
failing. Because the program's `expected_attach_type` is modified to
multi-uprobe at load time inside `bpf_object_init_progs()`, directly
calling the legacy attach options subsequently dies due to the type
mismatch.
How should we handle legacy manual attachments for auto-upgraded programs?
Should `bpf_program__attach_uprobe_opts()` be taught to internally
redirect to the multi-uprobe path if the expected type was upgraded?
Thanks,
Varun
Varun R Mallya (1):
libbpf: Auto-upgrade uprobes to multi-uprobes when supported
tools/lib/bpf/libbpf.c | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
--
2.52.0
next reply other threads:[~2026-02-12 15:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 15:20 Varun R Mallya [this message]
2026-02-12 15:20 ` [RFC PATCH bpf-next 1/1] libbpf: Auto-upgrade uprobes to multi-uprobes when supported Varun R Mallya
2026-02-13 0:06 ` Yonghong Song
2026-02-13 17:22 ` Varun R Mallya
2026-02-14 5:25 ` Yonghong Song
2026-02-18 19:07 ` Andrii Nakryiko
2026-02-19 5:31 ` Yonghong Song
2026-02-18 19:03 ` Andrii Nakryiko
2026-02-18 19:07 ` [RFC PATCH bpf-next 0/1] Upgrading uprobe and kprobe to their `multi` counterparts Andrii Nakryiko
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=20260212152013.17351-1-varunrmallya@gmail.com \
--to=varunrmallya@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
/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®