Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 09/11] perf symbol: Do not set binary type from symtab type
Date: Tue, 13 Oct 2026 17:35:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-170239@kernel.org> (raw)
In-Reply-To: <20261013172155.160869-10-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] perf: guest kmodules misidentified as host system path DSOs
--

commit 509bcd616550a20de7fa8d41090d38531f89cf60
Author: Namhyung Kim <namhyung@kernel.org>

perf symbol: Do not set binary type from symtab type

The DSO binary type is used to access the binary data, while the symtab
type is for the symbol table. This commit avoids setting the binary type
from the symtab type when loading symbols, and instead updates the binary
type only when opening the DSO.

> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 47241077ad260..1ca4cc5ec7db0 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -1491,9 +1491,10 @@ uint16_t dso__e_machine_endian(struct dso *dso, struct machine *machine, uint32_
>  			       bool *is_big_endian)
>  {
>  	uint16_t e_machine = EM_NONE;
> +	enum dso_binary_type dbt = dso__find_binary_type(dso);
>  	int fd;
>  
> -	switch (dso__binary_type(dso)) {
> +	switch (dbt) {

[Severity: High]
Will this change cause guest kmodules to be misidentified as host system
path DSOs?

By executing dso__find_binary_type() first, the code evaluates the priority
list in dso__find_binary_type_locked(), which checks
DSO_BINARY_TYPE__SYSTEM_PATH_DSO before falling back to dso__symtab_type(dso).

If the host filesystem happens to contain a module at the exact same absolute
path as the guest kernel module (e.g., /lib/modules/x.y.z/...), the
SYSTEM_PATH_DSO file check will succeed. This causes dso__find_binary_type()
to return SYSTEM_PATH_DSO instead of DSO_BINARY_TYPE__GUEST_KMODULE.

Because dso__e_machine_endian() receives SYSTEM_PATH_DSO, it will fall
through this fast-path switch, open the host file, and return the host's ELF
machine architecture. Could this break cross-platform perf analysis (such as
an x86_64 host analyzing an arm64 guest) by parsing the host's headers
instead of the guest's?

>  	case DSO_BINARY_TYPE__KALLSYMS:
>  	case DSO_BINARY_TYPE__GUEST_KALLSYMS:
>  	case DSO_BINARY_TYPE__VMLINUX:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013172155.160869-1-namhyung@kernel.org?part=9

  reply	other threads:[~2026-10-13 17:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 17:21 [PATCH v5 00/11] perf symbol: Properly seto DSO binary/symtab types Namhyung Kim
2026-10-13 17:21 ` [PATCH v5 01/11] perf tools: Remove redundant dso data init Namhyung Kim
2026-10-13 17:25   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 02/11] perf tools: Check ELF section type with name Namhyung Kim
2026-10-13 17:31   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 03/11] perf tools: Try linked debug files for DSO debug info Namhyung Kim
2026-10-13 17:34   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 04/11] perf symbol: Update symtab type of vmlinux from build-id cache Namhyung Kim
2026-10-13 17:32   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 05/11] perf symbol: Set binary/symtab type for split kallsyms Namhyung Kim
2026-10-13 17:30   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 06/11] perf symbol: Get rid of machine_or_dso_e_machine() Namhyung Kim
2026-10-13 17:37   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 07/11] perf tools: Factor out dso__find_binary_type() Namhyung Kim
2026-10-13 17:30   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 08/11] perf symbol: Set binary type for JIT map DSOs Namhyung Kim
2026-10-13 17:33   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 09/11] perf symbol: Do not set binary type from symtab type Namhyung Kim
2026-10-13 17:35   ` sashiko-bot [this message]
2026-10-13 17:21 ` [PATCH v5 10/11] perf annotate: Simplify symbol__disassemble() with dso binary_type Namhyung Kim
2026-10-13 17:29   ` sashiko-bot
2026-10-13 17:21 ` [PATCH v5 11/11] perf test: Fix dso data tests Namhyung Kim
2026-10-13 17:30   ` 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=sashiko-outbox-170239@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@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