* [PATCH] kbuild: detect module name collisions between '-' and '_'
@ 2026-11-03 11:04 Hamdy Abou El Anein
0 siblings, 0 replies; only message in thread
From: Hamdy Abou El Anein @ 2026-11-03 11:04 UTC (permalink / raw)
To: nathan; +Cc: nsc, linux-kbuild, linux-kernel, hamdy.aea
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 11:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 11:04 [PATCH] kbuild: detect module name collisions between '-' and '_' Hamdy Abou El Anein
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®