[PATCH v2 3/7] ubsan: Disable object-size sanitizer under GCC

From: Kees Cook
Date: Wed Dec 02 2020 - 19:46:32 EST


GCC's -fsanitize=object-size (as part of CONFIG_UBSAN_MISC) greatly
increases stack utilization. Do not allow this under GCC.

Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@xxxxxxxxxxxxxx/
Reviewed-by: Nathan Chancellor <natechancellor@xxxxxxxxx>
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
lib/Kconfig.ubsan | 3 +++
1 file changed, 3 insertions(+)

diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan
index 05147112b355..4190a99b1eaa 100644
--- a/lib/Kconfig.ubsan
+++ b/lib/Kconfig.ubsan
@@ -113,6 +113,9 @@ config UBSAN_UNSIGNED_OVERFLOW

config UBSAN_OBJECT_SIZE
def_bool UBSAN_MISC
+ # gcc hugely expands stack usage with -fsanitize=object-size
+ # https://lore.kernel.org/lkml/CAHk-=wjPasyJrDuwDnpHJS2TuQfExwe=px-SzLeN8GFMAQJPmQ@xxxxxxxxxxxxxx/
+ depends on !CC_IS_GCC
depends on $(cc-option,-fsanitize=object-size)

config UBSAN_BOOL
--
2.25.1