From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Alan Maguire" <almagui@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Alan Maguire" <alan.maguire@oracle.com>
Cc: <bpf@vger.kernel.org>
Subject: Re: resolve_btfids segmentation fault with CONFIG_DEBUG_INFO_BTF_INLINE
Date: Mon, 02 Nov 2026 17:55:41 +0000 [thread overview]
Message-ID: <DMKX2OGTCFW1.3K140NUR106DC@gmail.com> (raw)
In-Reply-To: <b32cb1d9-3ab7-4c2b-b18c-c8d1989637fd@kernel.org>
On Mon Nov 2, 2026 at 5:47 PM UTC, Alan Maguire wrote:
> On 10/31/26 8:36 PM, Alexei Starovoitov wrote:
>> Thanks for the report.
>>
>> It's a use-after-free in libbpf that resolve_btfids --inline runs into
>> on a module whose BTF has no strings of its own.
>>
>> With the patch below that module builds and ASAN is quiet. The output of
>> resolve_btfids for vmlinux and for the modules of my other test builds
>> is the same byte for byte with and without the patch.
>>
>> Please give it a try.
>>
>> [PATCH bpf] libbpf: Fix use-after-free in btf__add_type()
>>
>> For every string btf_rewrite_str() does:
>>
>> off = btf__add_str(p->dst, btf__str_by_offset(p->src, *str_off));
>>
>> When the string belongs to the base, the pointer goes into the raw data
>> of the base. btf__add_str() looks the string up in the base first,
>> btf__find_str() calls btf_ensure_modifiable() on the base, and that
>> frees the raw data. Then strset__find_str() reads the freed string.
>>
>> Make all the bases of dst modifiable before the pointer is taken.
>>
>> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>
>
> Thanks for the report and the proposed fix! I've reproduced the
> failure with Nathan's config + latest LLVM 24, and can confirm
> that the suggested fix works. So feel free to add
>
> Tested-by: Alan Maguire <almagui@kernel.org>
>
> I'll try and come up with a test that exercises the failure path.
> Thanks again!
Could you pls commandeer it and send a patch?
next prev parent reply other threads:[~2026-11-02 17:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 4:03 resolve_btfids segmentation fault with CONFIG_DEBUG_INFO_BTF_INLINE Nathan Chancellor
2026-10-31 20:36 ` Alexei Starovoitov
2026-11-02 17:47 ` Alan Maguire
2026-11-02 17:55 ` Alexei Starovoitov [this message]
2026-11-02 18:56 ` Nathan Chancellor
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=DMKX2OGTCFW1.3K140NUR106DC@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=almagui@kernel.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
--cc=nathan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.