Skip to content

Commit 818ab43

Browse files
committed
fortify: Update compile-time tests for Clang 14
Clang 14 introduces support for compiletime_assert(). Update the compile-time warning regex to catch Clang's variant of the warning text in preparation for Clang supporting CONFIG_FORTIFY_SOURCE. Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: linux-hardening@vger.kernel.org Cc: llvm@lists.linux.dev Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/lkml/YfbtQKtpyAM1hHiC@dev-arch.archlinux-ax161 Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 28e77cc commit 818ab43

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/test_fortify.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ if "$@" -Werror -c "$IN" -o "$OUT".o 2> "$TMP" ; then
4646
status="warning: unsafe ${FUNC}() usage lacked '$WANT' symbol in $IN"
4747
fi
4848
else
49-
# If the build failed, check for the warning in the stderr (gcc).
50-
if ! grep -q -m1 "error: call to .\b${WANT}\b." "$TMP" ; then
49+
# If the build failed, check for the warning in the stderr.
50+
# GCC:
51+
# ./include/linux/fortify-string.h:316:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
52+
# Clang 14:
53+
# ./include/linux/fortify-string.h:316:4: error: call to __write_overflow_field declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
54+
if ! grep -Eq -m1 "error: call to .?\b${WANT}\b.?" "$TMP" ; then
5155
status="warning: unsafe ${FUNC}() usage lacked '$WANT' warning in $IN"
5256
fi
5357
fi

0 commit comments

Comments
 (0)