diff --git a/SOURCES/kmod-0006-depmod-module_is_higher_priority-fix-modname-length-.patch b/SOURCES/kmod-0006-depmod-module_is_higher_priority-fix-modname-length-.patch new file mode 100644 index 0000000..88b1f7b --- /dev/null +++ b/SOURCES/kmod-0006-depmod-module_is_higher_priority-fix-modname-length-.patch @@ -0,0 +1,56 @@ +From dd73c8a2f5e8da3c38f6e16c63f249071d440378 Mon Sep 17 00:00:00 2001 +From: Yauheni Kaliuta +Date: Thu, 7 Dec 2017 20:59:54 +0200 +Subject: [PATCH 2/2] depmod: module_is_higher_priority: fix modname length + calculation + +depmod_module_is_higher_priority checks module's path if it is under +module root directory and if so uses relative to the root path to +lookup the module in override and search lists. + +Originally only relative path was used in the function, so the +variables with full path and and path length were changed: + + newpath += cfg->dirnamelen + 1; + newlen -= cfg->dirnamelen + 1; + oldpath += cfg->dirnamelen + 1; + oldlen -= cfg->dirnamelen + 1; + +Commit 7da6884e7357ac05772e90f6d7e63b1948103fc4 (depmod: implement +external directories support) changed the logic since it need the +full path to the module for comparations as well. + +Unfortunately, it introduce a mistake in calculation of the relative +paths replacing '-=' with assignment to a new variable -- the +'cfg->dirnamelen + 1' value must be substracted all together. It +breaks, for example, overrides lookup. + +Fix the calculation by putting braces around the value in the +subsctuction expression. + +Signed-off-by: Yauheni Kaliuta +--- + tools/depmod.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 7ff3e9ed191e..921dc5cc93eb 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -1118,11 +1118,11 @@ static int depmod_module_is_higher_priority(const struct depmod *depmod, const s + + if (strncmp(newpath, cfg->dirname, cfg->dirnamelen) == 0) { + relnewpath = newpath + cfg->dirnamelen + 1; +- relnewlen = newlen - cfg->dirnamelen + 1; ++ relnewlen = newlen - (cfg->dirnamelen + 1); + } + if (strncmp(oldpath, cfg->dirname, cfg->dirnamelen) == 0) { + reloldpath = oldpath + cfg->dirnamelen + 1; +- reloldlen = oldlen - cfg->dirnamelen + 1; ++ reloldlen = oldlen - (cfg->dirnamelen + 1); + } + + for (ov = cfg->overrides; ov != NULL; ov = ov->next) { +-- +2.15.1 + diff --git a/SPECS/kmod.spec b/SPECS/kmod.spec index 93882e6..8cd9c87 100644 --- a/SPECS/kmod.spec +++ b/SPECS/kmod.spec @@ -1,6 +1,6 @@ Name: kmod Version: 20 -Release: 15%{?dist}.6 +Release: 15%{?dist}.7 Summary: Linux kernel module management utilities Group: System Environment/Kernel @@ -18,6 +18,7 @@ Patch02: kmod-0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol.patch Patch03: kmod-0003-libkmod-Handle-long-lines-in-proc-modules.patch Patch04: kmod-0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU.patch Patch05: kmod-0005-depmod-backport-external-directories-support.patch +Patch06: kmod-0006-depmod-module_is_higher_priority-fix-modname-length-.patch BuildRequires: chrpath BuildRequires: zlib-devel @@ -69,6 +70,7 @@ applications that wish to load or unload Linux kernel modules. %patch03 -p1 -b .0003-libkmod-Handle-long-lines-in-proc-modules %patch04 -p1 -b .0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU %patch05 -p1 -b .0005-depmod-backport-external-directories-support +%patch06 -p1 -b .0006-depmod-module_is_higher_priority-fix-modname-length-.patch %build export V=1 @@ -136,6 +138,10 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf %{_libdir}/libkmod.so %changelog +* Wed Dec 13 2017 Yauheni Kaliuta - 20-15.el7_4.7 +- depmod: module_is_higher_priority: fix modname length calculation. + Resolves: rhbz#1525364. + * Thu Nov 16 2017 Yauheni Kaliuta - 20-15.el7_4.6 - Backport external directories support. Related: rhbz#1511943.