From: David <david@davidv.dev>
To: bpf@vger.kernel.org
Subject: Usage of kfuncs in tracepoints
Date: Mon, 12 Jan 2026 17:57:44 +0100 [thread overview]
Message-ID: <f5e6c1e4-f2f2-4982-a796-e3a49c522bbf@davidv.dev> (raw)
Hi
I'm trying to use `bpf_strstr` in a program that's running on kernel 6.18.2,
but I'm getting the following error on load:
> failed to find BTF for extern 'bpf_strstr' [53] section: -2
A minimal reproducer for this is:
```
extern int bpf_strstr(const char *s1__ign, const char *s2__ign);
SEC("tracepoint/syscalls/sys_enter_sendto")
int trace_sendto_entry(struct trace_event_raw_sys_enter *ctx)
{
char buf[128];
int pos = bpf_strstr(buf, "A");
}
```
My kernel was initially built with CONFIG_DEBUG_INFO_BTF=n, rebuilding with
CONFIG_DEBUG_INFO_BTF=y did not change the error.
I've only tried this with a stripped kernel image, which is 4MiB larger than
the image with no BTF info.
Running `bpftool btf dump` on the stripped iamge does show the kfunc:
```
$ bpftool btf dump file ~/git/linux-6.18.2/vmlinux | grep strstr
[26877] FUNC 'bpf_strstr' type_id=26855 linkage=static
[60337] FUNC 'strstr' type_id=60336 linkage=static
```
I'm running this program in a virtual machine with a custom init; running
through strace shows a failed load of `/proc/version_signature`, but I
assume a
fallback to `uname`.
```
faccessat2(AT_FDCWD, "/proc/version_signature", R_OK, AT_EACCESS) = -1
ENOENT (No such file or directory)
uname({sysname="Linux", nodename="(none)", ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f3fe6630000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f3fe662f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f3fe662e000
munmap(0x7f3fe662e000, 4096) = 0
munmap(0x7f3fe6630000, 8192 <unfinished ...>
nanosleep({tv_sec=0, tv_nsec=10000000} <unfinished ...>
futex(0x7f3fe6a44858, FUTEX_WAKE_PRIVATE, 1) = 1
munmap(0x7f3fe6839000, 16384 <unfinished ...>
sendto(3, "\1", 1, MSG_NOSIGNAL, NULL, 0 <unfinished ...>
futex(0x7f3fe6a43b70, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
sendto(3, "@", 1, MSG_NOSIGNAL, NULL, 0) = 1
sendto(3, "libbpf: failed to find BTF for e"..., 64, MSG_NOSIGNAL, NULL,
0) = 64
close(3)
```
Maybe there's another dependency I'm not aware of for kfuncs?
I'm not sure what I'm doing wrong, can you point me in the right direction?
David
next reply other threads:[~2026-01-12 16:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 16:57 David [this message]
2026-01-12 18:03 ` Usage of kfuncs in tracepoints Alan Maguire
2026-01-12 19:08 ` David
2026-01-13 8:05 ` Viktor Malik
2026-01-13 11:53 ` David
2026-01-13 12:08 ` Jiri Olsa
2026-01-13 13:58 ` David
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=f5e6c1e4-f2f2-4982-a796-e3a49c522bbf@davidv.dev \
--to=david@davidv.dev \
--cc=bpf@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