From: Nathan Chancellor <nathan@kernel.org>
To: iav@iav.lv
Cc: Kees Cook <kees@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
Nicolas Schier <nsc@kernel.org>
Subject: Re: [PATCH] fortify: Disable colored diagnostics in test_fortify.sh
Date: Fri, 25 Sep 2026 21:52:44 +0100 [thread overview]
Message-ID: <20260925205244.GA1518255@ax162> (raw)
In-Reply-To: <20260924-fortify-test-color-v1-1-37f6d50e31ec@iav.lv>
On Thu, Sep 24, 2026 at 11:34:29PM +0300, Igor Velkov via B4 Relay wrote:
> From: Igor Velkov <iav@iav.lv>
>
> When the build forces colored diagnostics, e.g. with
> KCFLAGS=-fdiagnostics-color=always, the compiler wraps the expected
> error in ANSI escape sequences and the grep does not match it. Every
> test then reports "lacked '__write_overflow' warning" although FORTIFY
> caught the overflow, and a real FORTIFY regression looks the same.
>
> warning: unsafe strcpy() usage lacked '__write_overflow' warning in lib/test_fortify/write_overflow-strcpy.c
>
> Pass -fdiagnostics-color=never after the caller's flags so that the
> test compile always emits plain text.
>
> Fixes: be58f7103700 ("fortify: Add compile-time FORTIFY_SOURCE tests")
> Assisted-by: LLM
> Signed-off-by: Igor Velkov <iav@iav.lv>
> ---
> Found in Armbian kernel builds, which pass -fdiagnostics-color=always
> in KCFLAGS: all 18 tests reported "lacked".
Hmmm, interesting default...
That said, seems reasonable to me. Presumably it is more complicated to
handle this in the regex.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Tested on arm64, 7.2.y, KCFLAGS=-fdiagnostics-color=always,
> building lib/test_fortify/ (tests ok out of 18):
>
> before after after, -D__NO_FORTIFY
> GCC 14.2 0 18 0
> clang 19.1.7 0 18 0
>
> An LLM assistant found the cause, wrote the fix and the changelog,
> and ran the tests; I reviewed all of it.
> ---
> lib/test_fortify/test_fortify.sh | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/test_fortify/test_fortify.sh b/lib/test_fortify/test_fortify.sh
> index ad6dd44fa31c..c07eb3302c9d 100644
> --- a/lib/test_fortify/test_fortify.sh
> +++ b/lib/test_fortify/test_fortify.sh
> @@ -37,7 +37,8 @@ export LANG=C
>
> status=
> # Attempt to build a source that is expected to fail with a specific warning.
> -if "$@" -Werror -c "$IN" -o "$OUT".o 2> "$TMP" ; then
> +# Disable colors so that the grep below can match the warning.
> +if "$@" -Werror -fdiagnostics-color=never -c "$IN" -o "$OUT".o 2> "$TMP" ; then
> # If the build succeeds, either the test has failed or the
> # warning may only happen at link time (Clang). In that case,
> # make sure the expected symbol is unresolved in the symbol list.
>
> ---
> base-commit: 760f96b7f54beb8dc6f85d97ac7854fddba86835
> change-id: 20260924-fortify-test-color-f34a31b56bcc
>
> Best regards,
> --
> Igor Velkov <iav@iav.lv>
>
>
--
Cheers,
Nathan
prev parent reply other threads:[~2026-09-25 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 20:34 Igor Velkov via B4 Relay
2026-09-25 18:58 ` Nicolas Schier
2026-09-25 20:52 ` Nathan Chancellor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925205244.GA1518255@ax162 \
--to=nathan@kernel.org \
--cc=iav@iav.lv \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nsc@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®