From: Hamdy Abou El Anein <info@daylightlinux.ch>
To: nathan@kernel.org
Cc: nsc@kernel.org, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org, hamdy.aea@protonmail.com
Subject: [PATCH] kbuild: detect module name collisions between '-' and '_'
Date: Tue, 3 Nov 2026 12:04:11 +0100 [thread overview]
Message-ID: <20261103110411.11698-1-info@daylightlinux.ch> (raw)
From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
Kbuild converts hyphens to underscores in KBUILD_MODNAME, and the module
loader treats both characters as equivalent. However, modules-check.sh
compares module basenames without normalization. Consequently, modules
named foo-bar.o and foo_bar.o pass the conflict check even though they
have the same effective module name.
Normalize basenames before checking for duplicates, and use awk to show
the original module paths in diagnostics. Preserve detection of exact
duplicates and leave distinct names unaffected.
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
scripts/modules-check.sh | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh
index 4c8da90..3d12dc5 100755
--- a/scripts/modules-check.sh
+++ b/scripts/modules-check.sh
@@ -13,10 +13,19 @@ exit_code=0
# Check uniqueness of module names
check_same_name_modules()
{
- for m in $(sed 's:.*/::' "$1" | sort | uniq -d)
+ for m in $(sed 's:.*/::; s/-/_/g' "$1" | sort | uniq -d)
do
echo "error: the following would cause module name conflict:" >&2
- sed -n "/\/$m/s:^\(.*\)\.o\$: \1.ko:p" "$1" >&2
+ awk -v name="$m" '
+ {
+ basename = $0
+ sub(/^.*\//, "", basename)
+ gsub(/-/, "_", basename)
+ if (basename == name) {
+ sub(/\.o$/, ".ko")
+ print " " $0
+ }
+ }' "$1" >&2
exit_code=1
done
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.0
reply other threads:[~2026-11-03 11:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261103110411.11698-1-info@daylightlinux.ch \
--to=info@daylightlinux.ch \
--cc=hamdy.aea@protonmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®