[PATCH 01/25] perf/core: Reject non-positive AUX snapshot sizes

James Clark james.clark at linaro.org
Fri Oct 16 06:14:32 PDT 2026



On 15/09/2026 16:48, Leo Yan wrote:
> The existing validation rejects negative copy errors but allows a zero
> return. In that case no AUX data was copied, but it is incorrectly
> passed to the alignment-padding check.
> 
> Reject zero together with negative errors before calculating the padding.
> This reports the invalid snapshot result and avoids treating a missing
> AUX payload as alignment padding.
> 
> Fixes: a4faf00d994c ("perf/aux: Allow using AUX data in perf samples")
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>   kernel/events/core.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index fe33fe15689d077e7f445c0b17d9c2e638c884a1..17355e4b8b7c6c106117153c9eb8509e6f9a41e3 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -8058,12 +8058,11 @@ static void perf_aux_sample_output(struct perf_event *event,
>   	size = perf_pmu_snapshot_aux(rb, sampler, handle, data->aux_size);
>   
>   	/*
> -	 * An error here means that perf_output_copy() failed (returned a
> -	 * non-zero surplus that it didn't copy), which in its current
> -	 * enlightened implementation is not possible. If that changes, we'd
> -	 * like to know.
> +	 * A negative return means that perf_output_copy() failed, while zero
> +	 * means that no AUX data was copied despite a non-zero request. Neither
> +	 * can be treated as alignment padding below.
>   	 */
> -	if (WARN_ON_ONCE(size < 0))
> +	if (WARN_ON_ONCE(size <= 0))
>   		goto out_put;
>   
>   	/*
> 

Reviewed-by: James Clark <james.clark at linaro.org>





More information about the linux-arm-kernel mailing list