From 2e6b80e4bcdb476e95c8cff46ebaae69f092abec Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 6 Jul 2023 15:11:23 -0500 Subject: [PATCH] cf: Undef _FORTIFY_SOURCE for use-after-free check Commit f2003ed68c (gcc: Avoid false positive use-after-free in crypto) added a configure check to detect whether the compiler we're using exhibits the use-after-free warning bug. We add -O0 to CFLAGS for the test to make sure the bug triggers for gcc 12, but if the user has specified, for example, CFLAGS=-D_FORTIFY_SOURCE=1, this causes the compile check to always fail: /usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] # warning _FORTIFY_SOURCE requires compiling with optimization (-O) This causes _OPENAFS_UAF_COMPILE_IFELSE to always fail, and so we throw an AC_MSG_ERROR during configure. To allow the build to continue with _FORTIFY_SOURCE, make sure _FORTIFY_SOURCE is undefined for this specific test. The compile test can then succeed with -O0 (unless we trigger the use-after-free bug, of course). Change-Id: Ib0d21b07b1e7892a6d411ee0c34a4ff7baf75cc3 Reviewed-on: https://gerrit.openafs.org/15499 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk --- src/cf/gcc.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cf/gcc.m4 b/src/cf/gcc.m4 index 7747807893..bcd30ac39d 100644 --- a/src/cf/gcc.m4 +++ b/src/cf/gcc.m4 @@ -31,7 +31,7 @@ AC_DEFUN([OPENAFS_GCC_UAF_BUG_CHECK],[ AS_IF([test "x$GCC" = "xyes"], [ AC_MSG_CHECKING([gcc use-after-free warning bug]) ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wall -Werror -O0" + CFLAGS="$CFLAGS -Wall -Werror -O0 -U_FORTIFY_SOURCE" _OPENAFS_UAF_COMPILE_IFELSE( [AC_MSG_RESULT(no)], [