Skip to contentSkip to conversation

Kbuild: make designated_init attribute fatal

PATCH In review Kees Cook 2 participants 2 messages Mar 21, 2017 Kbuild

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 Kbuild: make designated_init attribute fatal

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.

---
v2: update subject to more clearly describe change, Masahiro Yamada

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index b841fb36beb2..142ab7b96130 100644
@@ -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)
 
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
#1 lore raw

2017-03-21 9:14 GMT+09:00 Kees Cook <[email protected]>:

Quoted 10 lines

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.

---
v2: update subject to more clearly describe change, Masahiro Yamada
---

Applied to linux-kbuild/kbuild. Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada