[dm-devel] [PATCH v4 10/14] kbuild: Introduce FRAME_WARN_BUMP_FLAG

Kees Cook keescook at chromium.org
Wed Jul 11 20:36:15 UTC 2018


When building with CONFIG_FRAME_WARN, it is sometimes useful to
give certain compilation units small additional headroom. This is
normally useful when VLA removal exposes a large stack allocation,
especially with FRAME_WARN at 1024 or smaller. This adds 20%.

Signed-off-by: Kees Cook <keescook at chromium.org>
---
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index c9132594860b..06fe93edd052 100644
--- a/Makefile
+++ b/Makefile
@@ -684,7 +684,13 @@ endif
 
 ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
+# Small code (mostly exposed by VLA removal) needs some additional
+# headroom, especially for a FRAME_WARN of 1024. This adds 20% which
+# can be used by the CFLAG_FRAME_WARN_BUMP option.
+FRAME_WARN_BUMP_SIZE := $(shell expr $(CONFIG_FRAME_WARN) / 5 + $(CONFIG_FRAME_WARN))
+FRAME_WARN_BUMP_FLAG := $(call cc-option,-Wframe-larger-than=$(FRAME_WARN_BUMP_SIZE))
 endif
+export FRAME_WARN_BUMP_FLAG
 
 stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
 stackp-flags-$(CONFIG_STACKPROTECTOR)             := -fstack-protector
-- 
2.17.1




More information about the dm-devel mailing list