* [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size
@ 2025-04-16 17:20 Kees Cook
2025-04-16 18:43 ` Miguel Ojeda
2025-04-16 19:29 ` Kees Cook
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2025-04-16 17:20 UTC (permalink / raw)
To: Nathan Chancellor, Miguel Ojeda
Cc: Kees Cook, Nick Desaulniers, Bill Wendling, Justin Stitt,
Peter Zijlstra, Marco Elver, Przemek Kitszel, llvm, Andrew Morton,
Jan Hendrik Farr, Tony Ambardar, Alexander Potapenko, Uros Bizjak,
linux-kernel, linux-hardening
Clarify when __builtin_dynamic_object_size() is available. All our
supported Clang versions support it. GCC 12 and later support it. Link
to documentation for both.
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Marco Elver <elver@google.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: llvm@lists.linux.dev
---
include/linux/compiler_types.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 501cffddc2f4..20881cc761fa 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -449,6 +449,11 @@ struct ftrace_likely_data {
/*
* When the size of an allocated object is needed, use the best available
* mechanism to find it. (For cases where sizeof() cannot be used.)
+ *
+ * Optional: only supported since gcc >= 12
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
+ * clang: https://clang.llvm.org/docs/LanguageExtensions.html#evaluating-object-size
*/
#if __has_builtin(__builtin_dynamic_object_size)
#define __struct_size(p) __builtin_dynamic_object_size(p, 0)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size
2025-04-16 17:20 [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size Kees Cook
@ 2025-04-16 18:43 ` Miguel Ojeda
2025-04-16 19:29 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-04-16 18:43 UTC (permalink / raw)
To: Kees Cook
Cc: Nathan Chancellor, Miguel Ojeda, Nick Desaulniers, Bill Wendling,
Justin Stitt, Peter Zijlstra, Marco Elver, Przemek Kitszel, llvm,
Andrew Morton, Jan Hendrik Farr, Tony Ambardar,
Alexander Potapenko, Uros Bizjak, linux-kernel, linux-hardening
On Wed, Apr 16, 2025 at 7:20 PM Kees Cook <kees@kernel.org> wrote:
>
> Clarify when __builtin_dynamic_object_size() is available. All our
> supported Clang versions support it. GCC 12 and later support it. Link
> to documentation for both.
>
> Signed-off-by: Kees Cook <kees@kernel.org>
Looks good to me, thanks!
If you/someone is taking it through their tree:
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Cheers,
Miguel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size
2025-04-16 17:20 [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size Kees Cook
2025-04-16 18:43 ` Miguel Ojeda
@ 2025-04-16 19:29 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2025-04-16 19:29 UTC (permalink / raw)
To: Nathan Chancellor, Miguel Ojeda, Kees Cook
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, Peter Zijlstra,
Marco Elver, Przemek Kitszel, llvm, Andrew Morton,
Jan Hendrik Farr, Tony Ambardar, Alexander Potapenko, Uros Bizjak,
linux-kernel, linux-hardening
On Wed, 16 Apr 2025 10:20:20 -0700, Kees Cook wrote:
> Clarify when __builtin_dynamic_object_size() is available. All our
> supported Clang versions support it. GCC 12 and later support it. Link
> to documentation for both.
>
>
Applied to for-next/hardening, thanks!
[1/1] compiler_types: Identify compiler versions for __builtin_dynamic_object_size
https://git.kernel.org/kees/c/833dd6a6a1b1
Take care,
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-16 19:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 17:20 [PATCH] compiler_types: Identify compiler versions for __builtin_dynamic_object_size Kees Cook
2025-04-16 18:43 ` Miguel Ojeda
2025-04-16 19:29 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox