* [PATCH v2] Kbuild: make designated_init attribute fatal
@ 2017-03-21 0:14 Kees Cook
2017-03-21 17:53 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2017-03-21 0:14 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Michal Marek, linux-kbuild, Josh Triplett, linux-kernel
If a structure is marked with __attribute__((designated_init)) from
GCC or Sparse, it needs to have all static initializers using designated
initialization. Fail the build for any missing cases. This attribute will
be used by the randstruct plugin to make sure randomized structures are
being correctly initialized.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
v2: update subject to more clearly describe change, Masahiro Yamada
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index b841fb36beb2..142ab7b96130 100644
--- a/Makefile
+++ b/Makefile
@@ -795,6 +795,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
# enforce correct pointer usage
KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
+# Require designated initializers for all marked structures
+KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
+
# use the deterministic mode of AR if available
KBUILD_ARFLAGS := $(call ar-option,D)
--
2.7.4
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Kbuild: make designated_init attribute fatal
2017-03-21 0:14 [PATCH v2] Kbuild: make designated_init attribute fatal Kees Cook
@ 2017-03-21 17:53 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2017-03-21 17:53 UTC (permalink / raw)
To: Kees Cook
Cc: Michal Marek, Linux Kbuild mailing list, Josh Triplett,
Linux Kernel Mailing List
2017-03-21 9:14 GMT+09:00 Kees Cook <keescook@chromium.org>:
> If a structure is marked with __attribute__((designated_init)) from
> GCC or Sparse, it needs to have all static initializers using designated
> initialization. Fail the build for any missing cases. This attribute will
> be used by the randstruct plugin to make sure randomized structures are
> being correctly initialized.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> v2: update subject to more clearly describe change, Masahiro Yamada
> ---
Applied to linux-kbuild/kbuild. Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-21 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-21 0:14 [PATCH v2] Kbuild: make designated_init attribute fatal Kees Cook
2017-03-21 17:53 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox