tools/sched_ext: scx_flatcg: fix potential stack overflow from VLA in fcg_read_stats
authorDavid Carlier <devnexen@gmail.com>
Sat, 14 Feb 2026 07:32:05 +0000 (07:32 +0000)
committerTejun Heo <tj@kernel.org>
Tue, 17 Feb 2026 07:01:18 +0000 (21:01 -1000)
commitcabd76bbc03617e55c25f0b06167aa5e0b911a36
tree9859a1e8daf39945445ddf154b33dd6088313590
parent0b82cc331d2e23537670878c62c19ee3f4147a93
tools/sched_ext: scx_flatcg: fix potential stack overflow from VLA in fcg_read_stats

fcg_read_stats() had a VLA allocating 21 * nr_cpus * 8 bytes on the
stack, risking stack overflow on large CPU counts (nr_cpus can be up
to 512).

Fix by using a single heap allocation with the correct size, reusing
it across all stat indices, and freeing it at the end.

Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
tools/sched_ext/scx_flatcg.c