From: Ferran Duarri <ferran.duarri@me.com>
To: Nathan Chancellor <nathan@kernel.org>, Nicolas Schier <nsc@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Ferran Duarri <ferran.duarri@me.com>
Subject: [PATCH] kbuild: ubsan: skip UBSAN for external modules by default
Date: Thu, 20 Aug 2026 21:01:58 +0200 [thread overview]
Message-ID: <20260820190200.203185-1-ferran.duarri@me.com> (raw)
External modules built with KBUILD_EXTMOD set inherit UBSAN sanitizer
flags from the kernel's KBUILD_CFLAGS because is-kernel-object is 'y'
for any obj-m object. This silently breaks third-party modules whose
source code (e.g. VMware vmnet/vmmon) triggers UBSAN UB checks at
runtime, causing packet-forwarding failures and VM instability while
the module itself loads successfully.
Make UBSAN opt-in for external modules: skip the is-kernel-object 'y'
fallback when KBUILD_EXTMOD is set. External modules that explicitly
need UBSAN can still opt in by setting UBSAN_SANITIZE := y.
In-kernel module builds are not affected.
Signed-off-by: Ferran Duarri <ferran.duarri@me.com>
---
scripts/Makefile.lib | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0718e39cedda..393af3f970af 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -74,10 +74,10 @@ endif
ifeq ($(CONFIG_UBSAN),y)
_c_flags += $(if $(patsubst n%,, \
- $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)$(is-kernel-object)), \
+ $(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)$(if $(KBUILD_EXTMOD),,$(is-kernel-object))), \
$(CFLAGS_UBSAN))
_c_flags += $(if $(patsubst n%,, \
- $(UBSAN_INTEGER_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_INTEGER_WRAP)$(UBSAN_SANITIZE)$(is-kernel-object)), \
+ $(UBSAN_INTEGER_WRAP_$(target-stem).o)$(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_INTEGER_WRAP)$(UBSAN_SANITIZE)$(if $(KBUILD_EXTMOD),,$(is-kernel-object))), \
$(CFLAGS_UBSAN_INTEGER_WRAP))
endif
next reply other threads:[~2026-08-20 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 19:01 Ferran Duarri [this message]
2026-08-21 19:07 ` [PATCH] kbuild: ubsan: skip UBSAN for external modules by default Nathan Chancellor
2026-08-21 19:52 ` Nicolas Schier
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=20260820190200.203185-1-ferran.duarri@me.com \
--to=ferran.duarri@me.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@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 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.