From 9af7aa53eb2755783f818625d4a2bba68082eceb Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 25 Jun 2010 23:07:09 -0700 Subject: [PATCH] Set stack frame limit For all module/library functions ensure so stack frame exceeds 1024 bytes. Ideally this should be set lower to say 512 bytes but there are still numerous functions which exceed even this limit. For now this is set to 1024 to ensure we catch the worst offenders. Additionally, set the limit for ztest to 1024 bytes since the idea here is to catch stack issues in user space before we find them by overrunning a kernel stack. This should also be reduced to 512 bytes as soon as all the trouble makes are fixed. Finally, add -fstack-check to gcc build options when --enable-debug is specified at configure time. This ensures that each page on the stack will be touched and we will generate a segfault on stack overflow. Over time we can gradually fix the following functions: 536 zfs:dsl_deadlist_regenerate 536 zfs:dsl_load_sets 536 zfs:zil_parse 544 zfs:zfs_ioc_recv 552 zfs:dsl_deadlist_insert_bpobj 552 zfs:vdev_dtl_sync 584 zfs:copy_create_perms 608 zfs:ddt_class_contains 608 zfs:ddt_prefetch 608 zfs:__dprintf 616 zfs:ddt_lookup 648 zfs:dsl_scan_ddt 696 zfs:dsl_deadlist_merge 736 zfs:ddt_zap_walk 744 zfs:dsl_prop_get_all_impl 872 zfs:dnode_evict_dbufs --- cmd/ztest/Makefile.am | 2 ++ config/zfs-build.m4 | 2 +- lib/libzpool/Makefile.am | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am index 8f5ab2493..0573566e9 100644 --- a/cmd/ztest/Makefile.am +++ b/cmd/ztest/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/config/Rules.am +AM_CFLAGS += -Wframe-larger-than=1024 + DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libspl/include \ -I${top_srcdir}/lib/libefi/include \ diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index c83e11ce0..b5dac18e1 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -24,7 +24,7 @@ if test "$zfs_ac_debug" = yes; then [Define to 1 to enable debug tracing]) KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG " HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG " - USERDEBUG="-DDEBUG" + USERDEBUG="-DDEBUG -fstack-check" else AC_MSG_RESULT([no]) AC_DEFINE([NDEBUG], [1], diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index e28d7304b..785782051 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -1,5 +1,7 @@ include $(top_srcdir)/config/Rules.am +AM_CFLAGS += -Wframe-larger-than=1024 + SUBDIRS = include DEFAULT_INCLUDES += \ -I${top_srcdir}/lib/libzpool/include \ -- 2.40.0