Thread (10 messages) flat view 10 messages, 4 authors, 4d ago

RE: [PATCH v2] kstack_erase: suppress -grecord-gcc-switches for external module builds

From: Jaihind Yadav <hidden>
Date: 2026-08-16 08:11:08
Also in: linux-hardening, linux-kbuild, lkml

  Hi Nicolas, Nathan, Kees,

  Thanks for the feedback.

  Would it be acceptable to handle this generically for external modules in
  top-level kbuild (`Makefile`) instead of tying it to kstack_erase? I was
  thinking about adding:

    diff --git a/Makefile b/Makefile
    @@ -1057,6 +1057,10 @@ include $(addprefix $(srctree)/, $(include-y))
     # Do not add $(call cc-option,...) below this line. When you build the kernel
     # from the clean source tree, the GCC plugins do not exist at this point.

    +ifneq ($(KBUILD_EXTMOD),)
    +KBUILD_CFLAGS += -gno-record-gcc-switches
    +endif
    +
     # Add user supplied CPPFLAGS, AFLAGS, CFLAGS and RUSTFLAGS as the last assignments

  This would avoid per-module changes and also avoid coupling a generic
  compiler switch-recording behavior to `CONFIG_GCC_PLUGIN_STACKLEAK`.

  If this direction looks reasonable, I can send it as an RFC patch for review.

  Thanks,
  Jaihind

-----Original Message-----
From: Nathan Chancellor <nathan@kernel.org> 
Sent: Saturday, August 15, 2026 4:16 AM
To: Nicolas Schier <nsc@kernel.org>
Cc: Jaihind Yadav <redacted>; Kees Cook <kees@kernel.org>; linux-kbuild@vger.kernel.org; linux-modules@vger.kernel.org; linux-hardening@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] kstack_erase: suppress -grecord-gcc-switches for external module builds

WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.

On Fri, Aug 14, 2026 at 08:23:02PM +0200, Nicolas Schier wrote:
If there is a need for external kmods to to have

  make modules KCFLAGS=-gno-record-gcc-switches
Ah yeah, I forgot about KCFLAGS for the external module build. An external module could also include

  ccflags-y := -gno-record-gcc-switches

in its build file as well if this is a requirement of their build setup.
Perhaps we could revisit this within Kbuild if there is enough interest from various parties.

--
Cheers,
Nathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help