Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf header: Sanity check HEADER_PMU_MAPPINGS

Add upper bound check on pmu_num in process_pmu_mappings() to harden
against malformed perf.data files (max 4096).

Cc: Ian Rogers <irogers@google.com>
Assisted-by: Claude Code:claude-opus-4-6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Arnaldo Carvalho de Melo and committed by
Namhyung Kim
f613a6d6 a881fc56

+13
+13
tools/perf/util/header.c
··· 64 64 #endif 65 65 66 66 #define MAX_NUMA_NODES 4096 67 + #define MAX_PMU_MAPPINGS 4096 67 68 #define MAX_SCHED_DOMAINS 64 68 69 69 70 /* ··· 3068 3067 if (!pmu_num) { 3069 3068 pr_debug("pmu mappings not available\n"); 3070 3069 return 0; 3070 + } 3071 + 3072 + if (pmu_num > MAX_PMU_MAPPINGS) { 3073 + pr_err("Invalid HEADER_PMU_MAPPINGS: pmu_num (%u) > %u\n", 3074 + pmu_num, MAX_PMU_MAPPINGS); 3075 + return -1; 3076 + } 3077 + 3078 + if (ff->size < sizeof(u32) + pmu_num * 2 * sizeof(u32)) { 3079 + pr_err("Invalid HEADER_PMU_MAPPINGS: section too small (%zu) for %u PMUs\n", 3080 + ff->size, pmu_num); 3081 + return -1; 3071 3082 } 3072 3083 3073 3084 env->nr_pmu_mappings = pmu_num;