Re: [PATCH net-next v3 1/7] overflow: add DEFINE_FLEX() for on-stack allocs

From
Kees Cook <hidden>
Date
2023-08-16 20:38:04
Also in
intel-wired-lan, linux-hardening
Reply to
Przemek Kitszel, 2023-08-16
On Wed, Aug 16, 2023 at 10:06:17AM -0400, Przemek Kitszel wrote:
Add DEFINE_FLEX() macro for on-stack allocations of structs with
flexible array member.

Expose __struct_size() macro outside of fortify-string.h, as it could be
used to read size of structs allocated by DEFINE_FLEX().
Move __member_size() alongside it.
-Kees

Using underlying array for on-stack storage lets us to declare
known-at-compile-time structures without kzalloc().

Actual usage for ice driver is in following patches of the series.

Missing __has_builtin() workaround is moved up to serve also assembly
compilation with m68k-linux-gcc, see [1].
Error was (note the .S file extension):
In file included from ../include/linux/linkage.h:5,
                 from ../arch/m68k/fpsp040/skeleton.S:40:
../include/linux/compiler_types.h:331:5: warning: "__has_builtin" is not defined, evaluates to 0 [-Wundef]
  331 | #if __has_builtin(__builtin_dynamic_object_size)
      |     ^~~~~~~~~~~~~
../include/linux/compiler_types.h:331:18: error: missing binary operator before token "("
  331 | #if __has_builtin(__builtin_dynamic_object_size)
      |                  ^
Looks good to me! Thanks for working on this. :)

Acked-by: Kees Cook <redacted>

-- 
Kees Cook
Thread (21 messages) 21 messages, 7 authors, last reply 2023-08-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help