From: Michael Jeanson Date: Wed, 27 Jul 2022 14:54:53 +0000 (-0400) Subject: fix: removed accidental VLA in _get_num_possible_cpus() X-Git-Tag: v2.12.6~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=58683a1c4ed0ce78bf204d0ec999973959f70efa;p=lttng-ust.git fix: removed accidental VLA in _get_num_possible_cpus() The LTTNG_UST_PAGE_SIZE define can either point to a literal value or the sysconf() function making buf[] a VLA. Replace this by a cpumask specifc define that will always be a literal value. Change-Id: I8d329f314878e8018939f979861918969e3ec8ac Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/libringbuffer/smp.c b/libringbuffer/smp.c index 8b66b9e8..966556dc 100644 --- a/libringbuffer/smp.c +++ b/libringbuffer/smp.c @@ -30,6 +30,7 @@ #include #include +#include "align.h" #include "smp.h" #include "usterr-signal-safe.h" @@ -206,11 +207,10 @@ error: void _get_num_possible_cpus(void) { int ret; - int buf_len = sysconf(_SC_PAGE_SIZE); - char buf[buf_len]; + char buf[LTTNG_UST_CPUMASK_SIZE]; /* Get the possible cpu mask from sysfs, fallback to sysconf. */ - ret = get_possible_cpu_mask_from_sysfs((char *) &buf, buf_len); + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, LTTNG_UST_CPUMASK_SIZE); if (ret <= 0) goto fallback; diff --git a/libringbuffer/smp.h b/libringbuffer/smp.h index 1a880994..0db9e841 100644 --- a/libringbuffer/smp.h +++ b/libringbuffer/smp.h @@ -31,6 +31,8 @@ extern int __num_possible_cpus; +#define LTTNG_UST_CPUMASK_SIZE 4096 + /* * Get the CPU possible mask string from sysfs. *