BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 07/11] bpftool: Handle multi-split BTF by supporting multiple base BTFs
Date: Wed, 16 Sep 2026 07:54:36 +0000	[thread overview]
Message-ID: <20260916075437.09B2D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916074118.1007116-8-alan.maguire@oracle.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] bpf: evaluation of freed pointer in bpftool cleanup
- [Low] bpf: unbalanced braces in bpftool btf help string
--

commit 43f26ee1c8d2e52438682ffa46a3b61f16ff7512
Author: Alan Maguire <alan.maguire@oracle.com>

bpftool: Handle multi-split BTF by supporting multiple base BTFs

This commit updates bpftool to support multi-split BTF by allowing multiple
base BTF files to be specified via the -B argument. It updates the help text
and handles loading and freeing multiple nested BTF bases.

> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index bca0a3982f09b..bbe8f9ea144fa 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -1545,7 +1545,7 @@ static int do_help(int argc, char **argv)
>  		"       " HELP_SPEC_MAP "\n"
>  		"       " HELP_SPEC_PROGRAM "\n"
>  		"       " HELP_SPEC_OPTIONS " |\n"
> -		"                    {-B|--base-btf} }\n"
> +		"                    {[{-B|--base-btf} FILE]... }\n"

[Severity: Low]
Does this leave the opening brace from the HELP_SPEC_OPTIONS block unclosed?

The HELP_SPEC_OPTIONS macro starts a brace-enclosed block, but replacing the
single closing brace with a balanced group {[...]} might leave the overarching
list unclosed when the help output is printed.

> diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
> index 5ababd8f7d0a0..cff76be7d2e86 100644
> --- a/tools/bpf/bpftool/main.c
> +++ b/tools/bpf/bpftool/main.c

[ ... ]

> @@ -567,7 +572,18 @@ int main(int argc, char **argv)
>  	if (json_output)
>  		jsonw_destroy(&json_wtr);
>  
> -	btf__free(base_btf);
> +	while (base_btf) {
> +		new_base_btf = (struct btf *)btf__base_btf(base_btf);
> +		btf__free(base_btf);
> +		/*
> +		 * Do not free base BTF that is an owned .BTF.base ; leads
> +		 * to a double-free, so only free as far as the root base
> +		 * we explicitly read with -B above.
> +		 */
> +		if (base_btf == root_base_btf)
> +			break;

[Severity: Low]
Are we evaluating a freed pointer in this break condition?

Since btf__free(base_btf) is called just before this check, evaluating
base_btf against root_base_btf could invoke undefined behavior by reading the
dangling pointer, even if it is just an address comparison in a teardown path.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916074118.1007116-1-alan.maguire@oracle.com?part=7

  reply	other threads:[~2026-09-16  7:54 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  7:41 [PATCH v3 bpf-next 00/11] Support inline functions in BTF Alan Maguire
2026-09-16  7:41 ` [PATCH v3 bpf-next 01/11] btf: Extend UAPI to support BTF location (inline site) info Alan Maguire
2026-09-16  9:03   ` bot+bpf-ci
2026-09-16  7:41 ` [PATCH v3 bpf-next 02/11] libbpf: Add support for BTF kinds LOC[_PARAM|_PROTO|SEC] Alan Maguire
2026-09-16  7:55   ` sashiko-bot
2026-09-16  9:03   ` bot+bpf-ci
2026-09-16  7:41 ` [PATCH v3 bpf-next 03/11] selftests/bpf: Test helper support for BTF_KIND_LOC[_PARAM|_PROTO|SEC] Alan Maguire
2026-09-16  8:44   ` bot+bpf-ci
2026-09-18 18:34   ` Eduard Zingerman
2026-09-16  7:41 ` [PATCH v3 bpf-next 04/11] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to field iter tests Alan Maguire
2026-09-18 18:43   ` Eduard Zingerman
2026-09-16  7:41 ` [PATCH v3 bpf-next 05/11] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to dedup split tests Alan Maguire
2026-09-18 18:46   ` Eduard Zingerman
2026-09-16  7:41 ` [PATCH v3 bpf-next 06/11] selftests/bpf: BTF distill tests to ensure LOC[_PARAM|_PROTO] add to split BTF Alan Maguire
2026-09-18 19:59   ` Eduard Zingerman
2026-09-21 18:36     ` Alan Maguire
2026-09-16  7:41 ` [PATCH v3 bpf-next 07/11] bpftool: Handle multi-split BTF by supporting multiple base BTFs Alan Maguire
2026-09-16  7:54   ` sashiko-bot [this message]
2026-09-16  9:03   ` bot+bpf-ci
2026-09-16  7:41 ` [PATCH v3 bpf-next 08/11] bpftool: Document support for multi-split BTF Alan Maguire
2026-09-16  7:41 ` [PATCH v3 bpf-next 09/11] bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2026-09-16  7:55   ` sashiko-bot
2026-09-16  9:03   ` bot+bpf-ci
2026-09-16 22:07   ` Jiri Olsa
2026-09-17  8:27     ` Alan Maguire
2026-09-17 22:00       ` Jiri Olsa
2026-09-18  9:19         ` Alan Maguire
2026-09-18 13:01           ` Jiri Olsa
2026-09-17 16:06   ` Quentin Monnet
2026-09-17 17:32     ` Alan Maguire
2026-09-18  7:29     ` Alan Maguire
2026-09-18 20:51   ` Eduard Zingerman
2026-09-21 18:47     ` Alan Maguire
2026-09-21 21:46       ` Eduard Zingerman
2026-09-22 11:59         ` Quentin Monnet
2026-09-23  8:47           ` Alan Maguire
2026-09-16  7:41 ` [PATCH v3 bpf-next 10/11] selftests/bpf: Test bpftool dump of BTF location info Alan Maguire
2026-09-16  7:56   ` sashiko-bot
2026-09-16  9:03   ` bot+bpf-ci
2026-09-16  7:41 ` [PATCH v3 bpf-next 11/11] Documentation/bpf: Describe new location-related BTF kinds Alan Maguire
2026-09-16  8:01   ` sashiko-bot
2026-09-16  9:03   ` 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=20260916075437.09B2D1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=bpf@vger.kernel.org \
    --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