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_NUMA_TOPOLOGY

Add validation to process_numa_topology() to harden against malformed
perf.data files:

- Upper bound check on nr_nodes (max 4096)
- Minimum section size check before allocating

Cc: Jiri Olsa <jolsa@kernel.org>
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
4ba22301 22a2e2b2

+13
+13
tools/perf/util/header.c
··· 63 63 #include <event-parse.h> 64 64 #endif 65 65 66 + #define MAX_NUMA_NODES 4096 66 67 #define MAX_SCHED_DOMAINS 64 67 68 68 69 /* ··· 3005 3004 /* nr nodes */ 3006 3005 if (do_read_u32(ff, &nr)) 3007 3006 return -1; 3007 + 3008 + if (nr > MAX_NUMA_NODES) { 3009 + pr_err("Invalid HEADER_NUMA_TOPOLOGY: nr_nodes (%u) > %u\n", 3010 + nr, MAX_NUMA_NODES); 3011 + return -1; 3012 + } 3013 + 3014 + if (ff->size < sizeof(u32) + nr * (sizeof(u32) + 2 * sizeof(u64))) { 3015 + pr_err("Invalid HEADER_NUMA_TOPOLOGY: section too small (%zu) for %u nodes\n", 3016 + ff->size, nr); 3017 + return -1; 3018 + } 3008 3019 3009 3020 nodes = calloc(nr, sizeof(*nodes)); 3010 3021 if (!nodes)