BPF List
 help / color / mirror / Atom feed
From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/3] bpf: Export btf_get_module_btf() and btf_relocate_id()
Date: Fri, 15 May 2026 20:54:03 +0100	[thread overview]
Message-ID: <b158bfbc-dfa7-4e87-bda0-430bab4b7538@gmail.com> (raw)
In-Reply-To: <20260515175618.A4059C2BCB0@smtp.kernel.org>



On 5/15/26 6:56 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] API Asymmetry and Resource Leak due to unexported btf_put()
> --
> 
> commit 51050bef777abcb3d2969804b1e3693feb10a170
> Author: Mykyta Yatsenko <yatsenko@meta.com>
> 
> bpf: Export btf_get_module_btf() and btf_relocate_id()
> 
> This commit makes btf_get_module_btf() and btf_relocate_id() available outside
> kernel/bpf/btf.c by exporting them. This allows the tracing core to look up
> module BTF and translate split BTF ids.
> 
>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
>> index 77af44d8a3ad3..aa88d18247bda 100644
>> --- a/kernel/bpf/btf.c
>> +++ b/kernel/bpf/btf.c
> [ ... ]
>> @@ -8500,7 +8501,7 @@ struct module *btf_try_get_module(const struct btf *btf)
>>  /* Returns struct btf corresponding to the struct module.
>>   * This function can return NULL or ERR_PTR.
>>   */
>> -static struct btf *btf_get_module_btf(const struct module *module)
>> +struct btf *btf_get_module_btf(const struct module *module)
>>  {
> [ ... ]
>> @@ -8529,6 +8530,7 @@ static struct btf *btf_get_module_btf(const struct module *module)
>>  
>>  	return btf;
>>  }
>> +EXPORT_SYMBOL_GPL(btf_get_module_btf);
> 
> Because btf_get_module_btf() increments the reference count on the returned
> struct btf object using btf_get(), callers are required to release this
> reference by calling btf_put().
> 
> Since btf_put() is not exported, won't loadable modules using this new API
> fail to link or be forced to leak the struct btf reference?
> 
> Alternatively, if these functions are only meant for the tracing core, which
> is always built-in, are these EXPORT_SYMBOL_GPL declarations necessary?
> 

yes, I should drop EXPORT_SYMBOL_GPL, and move these function prototypes
to the header.

  reply	other threads:[~2026-05-15 19:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 16:41 [PATCH bpf-next 0/3] tracing: Expose tracepoint BTF ids via tracefs Mykyta Yatsenko
2026-05-15 16:41 ` [PATCH bpf-next 1/3] bpf: Export btf_get_module_btf() and btf_relocate_id() Mykyta Yatsenko
2026-05-15 17:56   ` sashiko-bot
2026-05-15 19:54     ` Mykyta Yatsenko [this message]
2026-05-15 16:41 ` [PATCH bpf-next 2/3] tracing: Expose tracepoint BTF ids via tracefs Mykyta Yatsenko
2026-05-15 18:25   ` sashiko-bot
2026-05-15 20:07     ` Mykyta Yatsenko
2026-05-15 22:48       ` Andrii Nakryiko
2026-05-15 16:41 ` [PATCH bpf-next 3/3] selftests/bpf: Add test for tracepoint btf_ids tracefs file Mykyta Yatsenko
2026-05-15 18:36   ` sashiko-bot
2026-05-15 20:09     ` Mykyta Yatsenko

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=b158bfbc-dfa7-4e87-bda0-430bab4b7538@gmail.com \
    --to=mykyta.yatsenko5@gmail.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