mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
perf kmem: Add bounds checks to tracepoint read values
Sanitize order and migrate_type values from tracepoint payloads before using them as array indexes. When processing page_alloc_event and page_free_event, verify that 'order' is less than MAX_PAGE_ORDER and 'migrate_type' is less than MAX_MIGRATE_TYPES. This guarantees that indexing into order_stats[MAX_PAGE_ORDER][MAX_MIGRATE_TYPES] remains strictly within bounds, avoiding out-of-bound heap or static segment accesses. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Jones <ajones@ventanamicro.com> Cc: Anup Patel <anup@brainfault.org> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Blake Jones <blakejones@google.com> Cc: Chen Ni <nichen@iscas.ac.cn> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Derek Foreman <derek.foreman@collabora.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Howard Chu <howardchu95@gmail.com> Cc: Hrishikesh Suresh <hrishikesh123s@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com> Cc: Leo Yan <leo.yan@arm.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quan Zhou <zhouquan@iscas.ac.cn> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Swapnil Sapkal <swapnil.sapkal@amd.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Tianyou Li <tianyou.li@intel.com> Cc: Yujie Liu <yujie.liu@intel.com> Cc: tanze <tanze@kylinos.cn> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e454fef5d2
commit
1bd2c9403e
|
|
@ -826,6 +826,16 @@ static int evsel__process_page_alloc_event(struct perf_sample *sample)
|
|||
.migrate_type = migrate_type,
|
||||
};
|
||||
|
||||
if (order >= MAX_PAGE_ORDER) {
|
||||
pr_debug("Out-of-bounds order %u\n", order);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (migrate_type >= MAX_MIGRATE_TYPES) {
|
||||
pr_debug("Out-of-bounds migratetype %u\n", migrate_type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (use_pfn)
|
||||
page = perf_sample__intval(sample, "pfn");
|
||||
else
|
||||
|
|
@ -892,6 +902,11 @@ static int evsel__process_page_free_event(struct perf_sample *sample)
|
|||
.order = order,
|
||||
};
|
||||
|
||||
if (order >= MAX_PAGE_ORDER) {
|
||||
pr_debug("Out-of-bounds order %u\n", order);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (use_pfn)
|
||||
page = perf_sample__intval(sample, "pfn");
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user