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 <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Andrew Deason 2023-07-06 15:11:23 -05:00 committed by Benjamin Kaduk
parent 0e06eb78f2
commit 2e6b80e4bc

View File

@ -31,7 +31,7 @@ AC_DEFUN([OPENAFS_GCC_UAF_BUG_CHECK],[
AS_IF([test "x$GCC" = "xyes"], [ AS_IF([test "x$GCC" = "xyes"], [
AC_MSG_CHECKING([gcc use-after-free warning bug]) AC_MSG_CHECKING([gcc use-after-free warning bug])
ac_save_CFLAGS="$CFLAGS" ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Werror -O0" CFLAGS="$CFLAGS -Wall -Werror -O0 -U_FORTIFY_SOURCE"
_OPENAFS_UAF_COMPILE_IFELSE( _OPENAFS_UAF_COMPILE_IFELSE(
[AC_MSG_RESULT(no)], [AC_MSG_RESULT(no)],
[ [