All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: York Jasper Niebuhr <yjn@yjn-systems.com>
Cc: Kees Cook <kees@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	franzen@sec.in.tum.de, linux-hardening@vger.kernel.org
Subject: [PATCH 2/3] gcc-plugins: sanemaker: make the no-op trap macros statement-safe
Date: Wed,  2 Sep 2026 16:33:42 -0700	[thread overview]
Message-ID: <20260902233349.1996922-2-kees@kernel.org> (raw)
In-Reply-To: <20260902233338.i.375-kees@kernel.org>

With CONFIG_SPSLR=y and CONFIG_SANEMAKER=n -- the baseline configuration
named in the cover letter -- the build fails:

  kernel/module/main.c:105:63: error: suggest braces around empty body
    in an 'if' statement [-Werror=empty-body]
    105 |                 (const char *)text->base + text->size);
  cc1: all warnings being treated as errors

The sanemaker_*() stubs expand to nothing when CONFIG_SANEMAKER is off,
and sanemaker_register_module_image() uses them as the body of an if:

	if (text->base && text->size)
		sanemaker_new_image_text(...);

which leaves "if (cond) ;".

Give the stubs the usual do { } while (0) body so they are valid
statements. No change when CONFIG_SANEMAKER=y.

Build tested ARCH=x86_64 defconfig+CONFIG_SPSLR=y with the patched
GCC 16.1.0 / GAS 2.46.1 toolchain, CONFIG_SANEMAKER unset.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: Kees Cook <kees@kernel.org>
---
 include/sanemaker/traps.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/sanemaker/traps.h b/include/sanemaker/traps.h
index bcb75198b18b..b9a39584de27 100644
--- a/include/sanemaker/traps.h
+++ b/include/sanemaker/traps.h
@@ -17,7 +17,7 @@ void __sanemaker_target_tag_trap(const void *ptr, const unsigned char *target);
 
 #else
 
-#define sanemaker_target_tag(ptr, type)
+#define sanemaker_target_tag(ptr, type) do { } while (0)
 
 #endif
 
@@ -32,7 +32,7 @@ void __sanemaker_target_untag_trap(const void *ptr);
 
 #else
 
-#define sanemaker_target_untag(ptr)
+#define sanemaker_target_untag(ptr) do { } while (0)
 
 #endif
 
@@ -50,7 +50,7 @@ void __sanemaker_finish_layout_trap(const void *fields,
 
 #else
 
-#define sanemaker_finish_layout(fields, target)
+#define sanemaker_finish_layout(fields, target) do { } while (0)
 
 #endif
 
@@ -90,7 +90,7 @@ void __sanemaker_signal_trap(sanemaker_signal_t signal);
 
 #else
 
-#define sanemaker_signal(signal)
+#define sanemaker_signal(signal) do { } while (0)
 
 #endif
 
@@ -125,10 +125,10 @@ void __sanemaker_drop_image_text_trap(const char *image, const void *begin,
 
 #else
 
-#define sanemaker_new_image(name, base)
-#define sanemaker_new_image_text(image, begin, end)
-#define sanemaker_drop_image(image)
-#define sanemaker_drop_image_text(image, begin, end)
+#define sanemaker_new_image(name, base) do { } while (0)
+#define sanemaker_new_image_text(image, begin, end) do { } while (0)
+#define sanemaker_drop_image(image) do { } while (0)
+#define sanemaker_drop_image_text(image, begin, end) do { } while (0)
 
 #endif
 
-- 
2.34.1


  parent reply	other threads:[~2026-09-02 23:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 23:33 [RFC][PATCH 0/3] SPSLR-v3 cleanups Kees Cook
2026-09-02 23:33 ` [PATCH 1/3] gcc-plugins: pinpoint: use quoted includes for internal headers Kees Cook
2026-09-02 23:33 ` Kees Cook [this message]
2026-09-02 23:33 ` [PATCH 3/3] gcc-plugins: pinpoint: move to subdirectory Kees Cook
2026-09-07 16:44 ` [RFC][PATCH 0/3] SPSLR-v3 cleanups Jasper Niebuhr

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=20260902233349.1996922-2-kees@kernel.org \
    --to=kees@kernel.org \
    --cc=ardb@kernel.org \
    --cc=franzen@sec.in.tum.de \
    --cc=linux-hardening@vger.kernel.org \
    --cc=yjn@yjn-systems.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.