Linux Modules
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org, linux-modules@vger.kernel.org,
	Petr Pavlu <petr.pavlu@suse.com>
Subject: Re: [PATCH v4 bpf-next 4/7] btf: Preserve string relocation maps for split BTF
Date: Fri, 9 Oct 2026 15:00:40 +0100	[thread overview]
Message-ID: <18c33c30-a9ee-4617-8828-c6896bf1c121@oracle.com> (raw)
In-Reply-To: <sashiko-outbox-165464@kernel.org>

On 09/10/2026 13:01, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
> - [High] btf: memory corruption and invalid string offsets with split base BTF
> - [High] bpf: heap buffer overflow in btf_relocate_map_distilled_base() on split BTF
> - [Medium] libbpf: NULL pointer dereference in btf_relocate() when btf has no base
> - [Low] bpf: btf_relocate_rewrite_strs prints empty string in warning
> --
> 
> commit 5e8ac630aea03f4aa4b3a237792c60ad3c7a0956
> Author: Alan Maguire <alan.maguire@oracle.com>
> 
> btf: Preserve string relocation maps for split BTF
> 
> Make btf_relocate() optionally return the string-offset map it builds
> while relocating a BTF relative to a distilled base. A subsequent split
> BTF object can use that map to rebase references to base strings.
> 
> Also account for the accumulated base string offset when assigning a
> new BTF base. This is required when the base is itself split.
> 
>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
>> index 592b71a838410..22dd123450c3e 100644
>> --- a/kernel/bpf/btf.c
>> +++ b/kernel/bpf/btf.c
>> @@ -1936,7 +1936,7 @@ void btf_set_base_btf(struct btf *btf, const struct btf *base_btf)
>>  {
>>  	btf->base_btf = (struct btf *)base_btf;
>>  	btf->start_id = btf_nr_types(base_btf);
>> -	btf->start_str_off = base_btf->hdr.str_len;
>> +	btf->start_str_off = base_btf->start_str_off + base_btf->hdr.str_len;
>>  }
> 
> [Severity: High]
> Since this allows using a split BTF as the base, will it cause out-of-bounds
> heap writes in tools/lib/bpf/btf_relocate.c:btf_relocate_map_distilled_base()?
> 

It is technically true that if we used split BTF as the basis for a distilled
.BTF.base, the string offset would be a problem. However we never do.
The reason .BTF.base exists is because we want a way to create stable base
BTF references for split BTF after potential base vmlinux changes.



  reply	other threads:[~2026-10-09 14:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 11:23 [PATCH v4 bpf-next 0/7] kbuild, bpf: Support inline info in BTF Alan Maguire
2026-10-09 11:23 ` [PATCH v4 bpf-next 1/7] resolve_btfids: Build separate main and inline BTF objects Alan Maguire
2026-10-09 11:23 ` [PATCH v4 bpf-next 2/7] resolve_btfids: Populate BTF link section Alan Maguire
2026-10-09 12:24   ` bot+bpf-ci
2026-10-09 11:23 ` [PATCH v4 bpf-next 3/7] kbuild, btf: Expose vmlinux inline BTF through sysfs Alan Maguire
2026-10-09 11:23 ` [PATCH v4 bpf-next 4/7] btf: Preserve string relocation maps for split BTF Alan Maguire
2026-10-09 12:01   ` sashiko-bot
2026-10-09 14:00     ` Alan Maguire [this message]
2026-10-09 11:23 ` [PATCH v4 bpf-next 5/7] btf: Relocate and expose module inline BTF Alan Maguire
2026-10-09 11:23 ` [PATCH v4 bpf-next 6/7] selftests/bpf: Test BTF sysfs inline representations Alan Maguire
2026-10-09 12:25   ` sashiko-bot
2026-10-11 14:29   ` Alexei Starovoitov
2026-10-09 11:23 ` [PATCH v4 bpf-next 7/7] selftests/bpf: Add a test verifying inline information Alan Maguire
2026-10-09 12:33   ` sashiko-bot
2026-10-11 14:40 ` [PATCH v4 bpf-next 0/7] kbuild, bpf: Support inline info in BTF patchwork-bot+netdevbpf

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=18c33c30-a9ee-4617-8828-c6896bf1c121@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=sashiko-reviews@lists.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