lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <174457175036.31282.16922756285239318022.tip-bot2@tip-bot2>
Date: Sun, 13 Apr 2025 19:15:50 -0000
From: "tip-bot2 for Thorsten Blum" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Thorsten Blum <thorsten.blum@...ux.dev>, Ingo Molnar <mingo@...nel.org>,
 Peter Zijlstra <peterz@...radead.org>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject:
 [tip: perf/core] perf/x86/intel/bts: Replace offsetof() with struct_size()

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     5c3627b6f0595f1ec27e6f5df903bd072e9b9136
Gitweb:        https://git.kernel.org/tip/5c3627b6f0595f1ec27e6f5df903bd072e9b9136
Author:        Thorsten Blum <thorsten.blum@...ux.dev>
AuthorDate:    Sun, 13 Apr 2025 12:41:09 +02:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Sun, 13 Apr 2025 21:05:50 +02:00

perf/x86/intel/bts: Replace offsetof() with struct_size()

Use struct_size() to calculate the number of bytes to allocate for a new
bts_buffer. Compared to offsetof(), struct_size() provides additional
compile-time checks (e.g., __must_be_array()).

Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: https://lore.kernel.org/r/20250413104108.49142-2-thorsten.blum@linux.dev
---
 arch/x86/events/intel/bts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index da03f53..16bc89c 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -101,7 +101,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,
 	if (overwrite && nr_buf > 1)
 		return NULL;
 
-	bb = kzalloc_node(offsetof(struct bts_buffer, buf[nr_buf]), GFP_KERNEL, node);
+	bb = kzalloc_node(struct_size(bb, buf, nr_buf), GFP_KERNEL, node);
 	if (!bb)
 		return NULL;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ