From: Thorsten Blum Date: Wed, 5 Mar 2025 12:31:34 +0000 (+0100) Subject: perf/x86: Annotate struct bts_buffer::buf with __counted_by() X-Git-Tag: v6.15-rc1~217^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e7adc81ae1b27ff565714d2933b291cf1e1271f;p=thirdparty%2Fkernel%2Flinux.git perf/x86: Annotate struct bts_buffer::buf with __counted_by() Add the __counted_by() compiler attribute to the flexible array member buf to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. No functional changes intended. Signed-off-by: Thorsten Blum Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20250305123134.215577-2-thorsten.blum@linux.dev --- diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index 8e09319544975..953868da82fb4 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -58,7 +58,7 @@ struct bts_buffer { local_t head; unsigned long end; void **data_pages; - struct bts_phys buf[]; + struct bts_phys buf[] __counted_by(nr_bufs); }; static struct pmu bts_pmu;