linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: Re-enable -Wunterminated-string-initialization
@ 2025-08-02  0:27 Kees Cook
  2025-08-02  0:43 ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2025-08-02  0:27 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Kees Cook, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kernel, llvm,
	linux-hardening

With the few remaining fixes now landed, we can re-enable the option
-Wunterminated-string-initialization for GCC. (Clang does not yet fully
understand the "nonstring" attribute.)

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas.schier@linux.dev>
Cc: <linux-kbuild@vger.kernel.org>
---
 scripts/Makefile.extrawarn | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index dca175fffcab..7ab8549485a4 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -78,8 +78,10 @@ KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
 KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
 KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
 
+ifdef CONFIG_CC_IS_CLANG
 # Currently, disable -Wunterminated-string-initialization as broken
 KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
+endif
 
 # The allocators already balk at large sizes, so silence the compiler
 # warnings for bounds checks involving those possible values. While
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: Re-enable -Wunterminated-string-initialization
  2025-08-02  0:27 [PATCH] kbuild: Re-enable -Wunterminated-string-initialization Kees Cook
@ 2025-08-02  0:43 ` Nathan Chancellor
  2025-08-02  0:55   ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2025-08-02  0:43 UTC (permalink / raw)
  To: Kees Cook
  Cc: Masahiro Yamada, Nicolas Schier, linux-kbuild, Nick Desaulniers,
	Bill Wendling, Justin Stitt, linux-kernel, llvm, linux-hardening

On Fri, Aug 01, 2025 at 05:27:40PM -0700, Kees Cook wrote:
> With the few remaining fixes now landed, we can re-enable the option
> -Wunterminated-string-initialization for GCC. (Clang does not yet fully
> understand the "nonstring" attribute.)
> 
> Signed-off-by: Kees Cook <kees@kernel.org>

What else does Clang need? Are bugs filed? I had requested support for
multidimensional arrays, which Aaron implemented pretty quickly (and the
tests seem pretty expansive):

https://github.com/llvm/llvm-project/commit/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e

> ---
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nicolas Schier <nicolas.schier@linux.dev>
> Cc: <linux-kbuild@vger.kernel.org>
> ---
>  scripts/Makefile.extrawarn | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index dca175fffcab..7ab8549485a4 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -78,8 +78,10 @@ KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
>  KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
>  KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
>  
> +ifdef CONFIG_CC_IS_CLANG
>  # Currently, disable -Wunterminated-string-initialization as broken
>  KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
> +endif
>  
>  # The allocators already balk at large sizes, so silence the compiler
>  # warnings for bounds checks involving those possible values. While
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: Re-enable -Wunterminated-string-initialization
  2025-08-02  0:43 ` Nathan Chancellor
@ 2025-08-02  0:55   ` Kees Cook
  2025-08-02  1:13     ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2025-08-02  0:55 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Masahiro Yamada, Nicolas Schier, linux-kbuild, Nick Desaulniers,
	Bill Wendling, Justin Stitt, linux-kernel, llvm, linux-hardening

On Fri, Aug 01, 2025 at 05:43:16PM -0700, Nathan Chancellor wrote:
> On Fri, Aug 01, 2025 at 05:27:40PM -0700, Kees Cook wrote:
> > With the few remaining fixes now landed, we can re-enable the option
> > -Wunterminated-string-initialization for GCC. (Clang does not yet fully
> > understand the "nonstring" attribute.)
> > 
> > Signed-off-by: Kees Cook <kees@kernel.org>
> 
> What else does Clang need? Are bugs filed? I had requested support for
> multidimensional arrays, which Aaron implemented pretty quickly (and the
> tests seem pretty expansive):
> 
> https://github.com/llvm/llvm-project/commit/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e

Oh! I missed that commit. Did that end up in Clang 21? Let me try some
test builds with a more recent Clang...

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: Re-enable -Wunterminated-string-initialization
  2025-08-02  0:55   ` Kees Cook
@ 2025-08-02  1:13     ` Nathan Chancellor
  2025-08-02 17:08       ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2025-08-02  1:13 UTC (permalink / raw)
  To: Kees Cook
  Cc: Masahiro Yamada, Nicolas Schier, linux-kbuild, Nick Desaulniers,
	Bill Wendling, Justin Stitt, linux-kernel, llvm, linux-hardening

On Fri, Aug 01, 2025 at 05:55:27PM -0700, Kees Cook wrote:
> On Fri, Aug 01, 2025 at 05:43:16PM -0700, Nathan Chancellor wrote:
> > On Fri, Aug 01, 2025 at 05:27:40PM -0700, Kees Cook wrote:
> > > With the few remaining fixes now landed, we can re-enable the option
> > > -Wunterminated-string-initialization for GCC. (Clang does not yet fully
> > > understand the "nonstring" attribute.)
> > > 
> > > Signed-off-by: Kees Cook <kees@kernel.org>
> > 
> > What else does Clang need? Are bugs filed? I had requested support for
> > multidimensional arrays, which Aaron implemented pretty quickly (and the
> > tests seem pretty expansive):
> > 
> > https://github.com/llvm/llvm-project/commit/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e
> 
> Oh! I missed that commit. Did that end up in Clang 21? Let me try some
> test builds with a more recent Clang...

Whoops, linked the wrong change (although that one is still good):

https://github.com/llvm/llvm-project/commit/3d4f979e271d2a1fe0906f4d1b16db108838f98f

But yes, both those changes are in 21.1.0-rc1. I uploaded -rc2 to
kernel.org a couple of days ago: https://kernel.org/pub/tools/llvm/

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kbuild: Re-enable -Wunterminated-string-initialization
  2025-08-02  1:13     ` Nathan Chancellor
@ 2025-08-02 17:08       ` Kees Cook
  0 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2025-08-02 17:08 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Masahiro Yamada, Nicolas Schier, linux-kbuild, Nick Desaulniers,
	Bill Wendling, Justin Stitt, linux-kernel, llvm, linux-hardening

On Fri, Aug 01, 2025 at 06:13:44PM -0700, Nathan Chancellor wrote:
> On Fri, Aug 01, 2025 at 05:55:27PM -0700, Kees Cook wrote:
> > On Fri, Aug 01, 2025 at 05:43:16PM -0700, Nathan Chancellor wrote:
> > > On Fri, Aug 01, 2025 at 05:27:40PM -0700, Kees Cook wrote:
> > > > With the few remaining fixes now landed, we can re-enable the option
> > > > -Wunterminated-string-initialization for GCC. (Clang does not yet fully
> > > > understand the "nonstring" attribute.)
> > > > 
> > > > Signed-off-by: Kees Cook <kees@kernel.org>
> > > 
> > > What else does Clang need? Are bugs filed? I had requested support for
> > > multidimensional arrays, which Aaron implemented pretty quickly (and the
> > > tests seem pretty expansive):
> > > 
> > > https://github.com/llvm/llvm-project/commit/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e
> > 
> > Oh! I missed that commit. Did that end up in Clang 21? Let me try some
> > test builds with a more recent Clang...
> 
> Whoops, linked the wrong change (although that one is still good):
> 
> https://github.com/llvm/llvm-project/commit/3d4f979e271d2a1fe0906f4d1b16db108838f98f
> 
> But yes, both those changes are in 21.1.0-rc1. I uploaded -rc2 to
> kernel.org a couple of days ago: https://kernel.org/pub/tools/llvm/

Ah yeah! Let me get this retested with the 21.1 release. I think we
don't need any special handling.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-02 17:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02  0:27 [PATCH] kbuild: Re-enable -Wunterminated-string-initialization Kees Cook
2025-08-02  0:43 ` Nathan Chancellor
2025-08-02  0:55   ` Kees Cook
2025-08-02  1:13     ` Nathan Chancellor
2025-08-02 17:08       ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).