linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf session: Fix handling when buffer exceeds 2 GiB
@ 2025-08-08 13:24 Leo Yan
  2025-08-15 20:17 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Yan @ 2025-08-08 13:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel,
	Tamas Zsoldos, Leo Yan

If a user specifies an AUX buffer larger than 2 GiB, the returned size
may exceed 0x80000000. Since the err variable is defined as a signed
32-bit integer, such a value overflows and becomes negative.

As a result, the perf record command reports an error:

  0x146e8 [0x30]: failed to process type: 71 [Unknown error 183711232]

Change the type of the err variable to a signed 64-bit integer to
accommodate large buffer sizes correctly.

Reported-by: Tamas Zsoldos <tamas.zsoldos@arm.com>
Fixes: d5652d865ea7 ("perf session: Add ability to skip 4GiB or more")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 26ae078278cd67fc5894c01cbb44c4b8fa81321a..09af486c83e4ff82e74f17f3da08d3bc3989768b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1402,7 +1402,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
 	const struct perf_tool *tool = session->tool;
 	struct perf_sample sample;
 	int fd = perf_data__fd(session->data);
-	int err;
+	s64 err;
 
 	perf_sample__init(&sample, /*all=*/true);
 	if ((event->header.type != PERF_RECORD_COMPRESSED &&

---
base-commit: 6235ce77749f45cac27f630337e2fdf04e8a6c73
change-id: 20250808-perf_fix_big_buffer_size-e28f618df61c

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf session: Fix handling when buffer exceeds 2 GiB
  2025-08-08 13:24 [PATCH] perf session: Fix handling when buffer exceeds 2 GiB Leo Yan
@ 2025-08-15 20:17 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2025-08-15 20:17 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel,
	Tamas Zsoldos

On Fri, Aug 08, 2025 at 02:24:40PM +0100, Leo Yan wrote:
> If a user specifies an AUX buffer larger than 2 GiB, the returned size
> may exceed 0x80000000. Since the err variable is defined as a signed
> 32-bit integer, such a value overflows and becomes negative.
> 
> As a result, the perf record command reports an error:
> 
>   0x146e8 [0x30]: failed to process type: 71 [Unknown error 183711232]
> 
> Change the type of the err variable to a signed 64-bit integer to
> accommodate large buffer sizes correctly.
> 
> Reported-by: Tamas Zsoldos <tamas.zsoldos@arm.com>
> Fixes: d5652d865ea7 ("perf session: Add ability to skip 4GiB or more")
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/perf/util/session.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 26ae078278cd67fc5894c01cbb44c4b8fa81321a..09af486c83e4ff82e74f17f3da08d3bc3989768b 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1402,7 +1402,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
>  	const struct perf_tool *tool = session->tool;
>  	struct perf_sample sample;
>  	int fd = perf_data__fd(session->data);
> -	int err;
> +	s64 err;
>  
>  	perf_sample__init(&sample, /*all=*/true);
>  	if ((event->header.type != PERF_RECORD_COMPRESSED &&
> 
> ---
> base-commit: 6235ce77749f45cac27f630337e2fdf04e8a6c73
> change-id: 20250808-perf_fix_big_buffer_size-e28f618df61c
> 
> Best regards,
> -- 
> Leo Yan <leo.yan@arm.com>
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-15 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 13:24 [PATCH] perf session: Fix handling when buffer exceeds 2 GiB Leo Yan
2025-08-15 20:17 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).