BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: bpf@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v1 2/8] perf/core: Add BUILD_ID_OFFSET to UAPI
Date: Fri, 07 Aug 2026 07:42:56 +0000	[thread overview]
Message-ID: <20260807074257.0305E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807071818.718751-3-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The commit introduces `PERF_SAMPLE_BUILD_ID_OFFSET` and `PERF_SAMPLE_CALLCHAIN_BUILD_ID_OFFSET` to the UAPI and bumps `PERF_SAMPLE_MAX`, but fails to implement the corresponding sample generation logic in the core kernel.
- [Medium] The UAPI header update is applied inconsistently between `include/` and `tools/include/`, causing divergence and leaving the canonical kernel header undocumented.
- [Medium] The ABI documentation comment references `struct build_id`, an undeclared structure in the canonical UAPI headers, resulting in an opaque and confusing binary layout.
--

--- Patch [2]: [RFC PATCH v1 2/8] perf/core: Add BUILD_ID_OFFSET to UAPI ---
commit 16454ab98fa038eb527938712933e7e488db3d27
Author: Ian Rogers <irogers@google.com>

perf/core: Add BUILD_ID_OFFSET to UAPI
    
This commit introduces PERF_SAMPLE_BUILD_ID_OFFSET and
PERF_SAMPLE_CALLCHAIN_BUILD_ID_OFFSET to the UAPI and bumps the internal
validation limit.

> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index fd10aa8d697f2..f0712c1471d3d 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -165,8 +165,10 @@ enum perf_event_sample_format {
>  	PERF_SAMPLE_DATA_PAGE_SIZE		= 1U << 22,
>  	PERF_SAMPLE_CODE_PAGE_SIZE		= 1U << 23,
>  	PERF_SAMPLE_WEIGHT_STRUCT		= 1U << 24,
> +	PERF_SAMPLE_BUILD_ID_OFFSET		= 1U << 25,
> +	PERF_SAMPLE_CALLCHAIN_BUILD_ID_OFFSET	= 1U << 26,
>  
> -	PERF_SAMPLE_MAX = 1U << 25,		/* non-ABI */
> +	PERF_SAMPLE_MAX = 1U << 27,		/* non-ABI */
>  };

[Severity: High]
Since PERF_SAMPLE_MAX is increased, perf_copy_attr() will now accept these
new sample types from userspace. However, is there missing core kernel logic
to actually process these bits?

Looking at the core kernel code, perf_output_sample() and
__perf_event_header_size() appear to lack handlers for the new bits. If a
userspace application requests these fields, it seems the kernel will not
allocate space for them or write them to the ring buffer.

When the userspace parser subsequently decodes the stream based on the
attr.sample_type bitmask, won't it read past the end of the truncated sample
and misinterpret the next event header as data?

> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index 2479a38883d00..d5660e2d6b603 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h

[ ... ]

> @@ -1054,6 +1056,13 @@ enum perf_event_type {
>  	 *	{ u64			code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE
>  	 *	{ u64			size;
>  	 *	  char			data[size]; } && PERF_SAMPLE_AUX
> +	 *	{ struct build_id	bid;
> +	 *	  u64			offset; } && PERF_SAMPLE_BUILD_ID_OFFSET

[Severity: Medium]
It looks like this payload documentation block was only added to the tools
side header (tools/include/uapi/linux/perf_event.h). Was it intended to be
added to the canonical include/uapi/linux/perf_event.h as well?

Missing the canonical header causes divergence between the kernel and tools
headers, which might trigger check-headers.sh warnings and leave users relying
on the kernel headers without documentation for the new ABI.

[Severity: Medium]
Also, regarding the struct build_id payload documentation here, this structure
appears to be undeclared in the canonical kernel UAPI header.

Does the use of struct build_id here collide with the internal tools structure
of the same name? The internal tools/perf/util/build-id.h structure has a
layout of:

  u8 data[20];
  u8 size;

Whereas the ABI typically uses a different layout (e.g., u8 size; u8 res1;
u16 res2; u8 data[20];). Could this cause layout confusion for tool developers
attempting to parse the ABI?

> +	 *	{ u64			nr;
> +	 *	  struct {
> +	 *		struct build_id	bid;
> +	 *		u64 offset;
> +	 *	  }[nr]; } && PERF_SAMPLE_CALLCHAIN_BUILD_ID_OFFSET
>  	 * };
>  	 */
>  	PERF_RECORD_SAMPLE			= 9,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807071818.718751-1-irogers@google.com?part=2

  reply	other threads:[~2026-08-07  7:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  7:18 [RFC PATCH v1 0/8] perf/core, perf/tools: Add PERF_SAMPLE_BUILD_ID_OFFSET support Ian Rogers
2026-08-07  7:18 ` [RFC PATCH v1 1/8] perf event: Factor build_id out into its own top-level struct Ian Rogers
2026-08-07  7:33   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 2/8] perf/core: Add BUILD_ID_OFFSET to UAPI Ian Rogers
2026-08-07  7:42   ` sashiko-bot [this message]
2026-08-07  7:18 ` [RFC PATCH v1 3/8] perf/core: Implement BUILD_ID_OFFSET sample type Ian Rogers
2026-08-07  7:54   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 4/8] perf: Refactor thread map and symbol APIs to take perf_sample Ian Rogers
2026-08-07  8:20   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 5/8] perf tools: Internal support for BUILD_ID_OFFSET Ian Rogers
2026-08-07  8:41   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 6/8] perf inject: Extend perf inject to support bid_offset conversion Ian Rogers
2026-08-07  9:18   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 7/8] perf record: Add --buildid-offset option Ian Rogers
2026-08-07  9:47   ` sashiko-bot
2026-08-07  7:18 ` [RFC PATCH v1 8/8] perf tests: Add build_id_offset test coverage Ian Rogers
2026-08-07  9:58   ` sashiko-bot
2026-08-07 11:18 ` [RFC PATCH v1 0/8] perf/core, perf/tools: Add PERF_SAMPLE_BUILD_ID_OFFSET support Peter Zijlstra

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=20260807074257.0305E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@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