From: Nathan Chancellor <nathan@kernel.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Nicolas Schier <nsc@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>, Kees Cook <kees@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH] kbuild: add -fdiagnostics-show-inlining-chain for FORTIFY_SOURCE
Date: Fri, 27 Mar 2026 23:18:37 +0100 [thread overview]
Message-ID: <20260327221837.GA3622500@ax162> (raw)
In-Reply-To: <20260327-kbuild-show-inlining-v1-1-730ac2cae571@google.com>
On Fri, Mar 27, 2026 at 02:59:20PM -0700, Justin Stitt wrote:
> Clang recently added -fdiagnostics-show-inlining-chain [1] to improve
> the visibility of inlining chains in diagnostics. This is particularly
> useful for CONFIG_FORTIFY_SOURCE where detections can happen deep in
> inlined functions.
>
> Add this flag to KBUILD_CFLAGS when CONFIG_FORTIFY_SOURCE is enabled
> and the compiler supports it.
>
> Link: https://github.com/llvm/llvm-project/pull/174892 [1]
> Link: https://github.com/ClangBuiltLinux/linux/issues/1571
> Signed-off-by: Justin Stitt <justinstitt@google.com>
> ---
> Makefile | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index e1279c4d5b24..978726aeb1ef 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -973,6 +973,12 @@ KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
> # Get details on warnings generated due to GCC value tracking.
> KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2)
>
> +# Show inlining chain notes for FORTIFY_SOURCE-related diagnostics.
> +# GCC does this by default while Clang 23+ supports a flag.
> +ifdef CONFIG_FORTIFY_SOURCE
While this is indeed particularly useful for CONFIG_FORTIFY_SOURCE, this
impacts the warning and error attributes, which can be used anywhere
(see __bad_copy_from() for example). Is this being wrapped due to the
potential compile time impact? Can we use something like hyperfine to
quantify it and see if the impact is worth the trade off of always
having it enabled for friendlier diagnostics? If not, maybe worth
adding a Kconfig option that is force selected by FORTIFY_SOURCE with
clang or can be optionally enabled by a user?
> +KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain)
> +endif
> +
> # Clear used registers at func exit (to reduce data lifetime and ROP gadgets).
> ifdef CONFIG_ZERO_CALL_USED_REGS
> KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
>
> ---
> base-commit: 7df48e36313029e4c0907b2023905dd7213fd678
> change-id: 20260327-kbuild-show-inlining-557d31d2293a
>
> Best regards,
> --
> Justin Stitt <justinstitt@google.com>
>
next prev parent reply other threads:[~2026-03-27 22:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 21:59 [PATCH] kbuild: add -fdiagnostics-show-inlining-chain for FORTIFY_SOURCE Justin Stitt
2026-03-27 22:18 ` Nathan Chancellor [this message]
2026-03-27 22:29 ` Justin Stitt
2026-03-30 3:59 ` Kees Cook
2026-03-30 5:36 ` Nathan Chancellor
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=20260327221837.GA3622500@ax162 \
--to=nathan@kernel.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nick.desaulniers+lkml@gmail.com \
--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