BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: linux-modules@vger.kernel.org, "Petr Pavlu" <petr.pavlu@suse.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 3/7] kbuild, btf: Expose vmlinux inline BTF through sysfs
Date: Sat, 03 Oct 2026 19:56:47 +0000	[thread overview]
Message-ID: <20261003195648.25B841F0089C@smtp.kernel.org> (raw)
In-Reply-To: <20261003194323.817885-4-alan.maguire@oracle.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] bpf: btf: Unvalidated zero-size allocation triggers WARN_ON_ONCE in vmalloc_user
- [Low] bpf: btf: Linkage fails for sha256 when CONFIG_DEBUG_INFO_BTF_INLINE=m
--

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

kbuild, btf: Expose vmlinux inline BTF through sysfs

This commit introduces support for embedded and module-delivered vmlinux
inline BTF payloads, making them available via sysfs. It also sets up deferred
binding for a module-provided .BTF.inline section.

> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 134b15a44625e..24abfff1ddc3c 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -432,6 +438,19 @@ config DEBUG_INFO_BTF_MODULES
>  	help
>  	  Generate compact split BTF type information for kernel modules.
>  
> +config DEBUG_INFO_BTF_INLINE
> +	tristate "Provide information about inline sites in BTF"
> +	default n
> +	depends on DEBUG_INFO_BTF && PAHOLE_HAS_INLINE && SYSFS
> +	select DEBUG_INFO_BTF_MODULES if MODULES
> +	select CRYPTO_LIB_SHA256

[Severity: Low]
Does this cause a linkage failure when CONFIG_DEBUG_INFO_BTF_INLINE is built
as a module?

Because this is a tristate, selecting CRYPTO_LIB_SHA256 here means it will 
evaluate to 'm' if the inline feature is configured as a module. 

However, the crypto library is called directly from the built-in core kernel
object kernel/bpf/btf.c:

kernel/bpf/btf.c:btf_verify_link() {
    ...
    sha256(data, data_size, actual_digest);
    ...
}

A built-in object cannot resolve a symbol exported by a loadable module,
which will result in an 'undefined reference to sha256' error at build time.

> +	help
> +	  Generate information about inline sites in .BTF.inline sections.

[ ... ]

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 0630675377aaa..732ba06846675 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c

[ ... ]

> @@ -9015,21 +9016,122 @@ static DEFINE_MUTEX(btf_module_mutex);
> +static int btf_module_handle_vmlinux_inline(const struct module *mod)
> +{
> +	void *data = NULL;
> +
> +	if (!vmlinux_inline_link || strcmp(mod->name, vmlinux_inline_link->module_name))
> +		return -ENOENT;
> +
> +	data = vmalloc_user(mod->btf_inline_data_size);

[Severity: Medium]
Could this trigger a WARN_ON_ONCE splat in the memory allocation paths?

If a user with CAP_SYS_MODULE loads a module matching
vmlinux_inline_link->module_name, but the module has no .BTF.inline section
(or its size is exactly 0), mod->btf_inline_data_size will be set to 0.

Calling vmalloc_user(0) here happens before the size is validated against 
link->btf_size, which causes a kernel warning in __vmalloc_node_range_noprof.

> +	if (!data)
> +		return -ENOMEM;
> +	memcpy(data, mod->btf_inline_data, mod->btf_inline_data_size);
> +
> +	if (!btf_verify_link(vmlinux_inline_link, mod, data, mod->btf_inline_data_size) ||
> +	    !sysfs_btf_update(vmlinux_inline_attr, data)) {
> +		kvfree(data);
> +		return -EINVAL;
> +	}
> +	return 0;
> +}

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

  reply	other threads:[~2026-10-03 19:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03 19:43 [PATCH v3 bpf-next 0/7] kbuild, bpf: Support inline info in BTF Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 1/7] resolve_btfids: Build separate main and inline BTF objects Alan Maguire
2026-10-03 20:27   ` bot+bpf-ci
2026-10-06 17:30     ` Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 2/7] resolve_btfids: Populate BTF link section Alan Maguire
2026-10-03 20:27   ` bot+bpf-ci
2026-10-03 19:43 ` [PATCH v3 bpf-next 3/7] kbuild, btf: Expose vmlinux inline BTF through sysfs Alan Maguire
2026-10-03 19:56   ` sashiko-bot [this message]
2026-10-06 18:12     ` Alan Maguire
2026-10-03 20:41   ` bot+bpf-ci
2026-10-06 18:42     ` Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 4/7] btf: Preserve string relocation maps for split BTF Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 5/7] btf: Relocate and expose module inline BTF Alan Maguire
2026-10-03 19:59   ` sashiko-bot
2026-10-06 18:56     ` Alan Maguire
2026-10-03 20:27   ` bot+bpf-ci
2026-10-03 19:43 ` [PATCH v3 bpf-next 6/7] selftests/bpf: Test BTF sysfs inline representations Alan Maguire
2026-10-03 19:54   ` sashiko-bot
2026-10-03 19:43 ` [PATCH v3 bpf-next 7/7] selftests/bpf: Add a test verifying inline information Alan Maguire
2026-10-03 19:54   ` sashiko-bot

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=20261003195648.25B841F0089C@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=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