summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2026-04-08 14:32:00 -0300
committerNamhyung Kim <namhyung@kernel.org>2026-04-08 19:21:05 -0700
commitfc32ae6df83d78145391bfdaf0e213babad8e93f (patch)
tree64232a9bc48a14a5f6642c79d9fa4516b27bafe5 /tools
parentc89f35def821874d993bb1c033a7c3cbd32bccdb (diff)
perf header: Use a max number of command line args
Sashiko suggests we use some reasonable max number of args to avoid overflows when reading perf.data files, do it. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/header.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index a3b7b796639b..a18f216f77c2 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2795,6 +2795,9 @@ process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
return 0;
}
+// Some reasonable arbitrary max for the number of command line arguments
+#define MAX_CMDLINE_NR 32768
+
static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused)
{
struct perf_env *env = &ff->ph->env;
@@ -2804,6 +2807,9 @@ static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused)
if (do_read_u32(ff, &nr))
return -1;
+ if (nr > MAX_CMDLINE_NR)
+ return -1;
+
env->nr_cmdline = nr;
cmdline = zalloc(ff->size + nr + 1);