diff --git a/SOURCES/kmod-20-9.el7-0001-depmod-Don-t-fall-back-to-uname-on-bad-version.patch b/SOURCES/kmod-20-9.el7-0001-depmod-Don-t-fall-back-to-uname-on-bad-version.patch new file mode 100644 index 0000000..717c678 --- /dev/null +++ b/SOURCES/kmod-20-9.el7-0001-depmod-Don-t-fall-back-to-uname-on-bad-version.patch @@ -0,0 +1,43 @@ +From 1f5010924500a4fd83047584d1fbdba5517dffa2 Mon Sep 17 00:00:00 2001 +From: Tony Camuso +Date: Fri, 24 Jun 2016 12:37:48 -0400 +Subject: [RHEL-7.3 PATCH 1/3] depmod: Don't fall back to uname on bad version + +Cherry-picked without conflicts from the following upstream commit. + +commit f3f62f5ec3b23823b2ce02e37bc707dc85c56461 +Author: Laura Abbott +Date: Mon Sep 28 15:39:14 2015 -0700 + + depmod: Don't fall back to uname on bad version + + Currently, if a value that doesn't match a kernel version + ("%u.%u") is passed in, depmod silently falls back to + using uname. Rather than try and work around the caller passing + bad data, just exit out instead. + +Signed-off-by: Tony Camuso +--- + tools/depmod.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 231b9ab..8d5c671 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -2475,7 +2475,11 @@ static int do_depmod(int argc, char *argv[]) + } + } + +- if (optind < argc && is_version_number(argv[optind])) { ++ if (optind < argc) { ++ if (!is_version_number(argv[optind])) { ++ ERR("Bad version passed %s\n", argv[optind]); ++ goto cmdline_failed; ++ } + cfg.kversion = argv[optind]; + optind++; + } else { +-- +1.8.3.1 + diff --git a/SOURCES/kmod-20-9.el7-0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol.patch b/SOURCES/kmod-20-9.el7-0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol.patch new file mode 100644 index 0000000..70a9900 --- /dev/null +++ b/SOURCES/kmod-20-9.el7-0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol.patch @@ -0,0 +1,40 @@ +From 6708fbf7d26c6241cc37614c632bba1ce4ef1a4e Mon Sep 17 00:00:00 2001 +From: Tony Camuso +Date: Fri, 24 Jun 2016 12:38:25 -0400 +Subject: [RHEL-7.3 PATCH 2/3] depmod: Ignore PowerPC64 ABIv2 .TOC. symbol + +Cherry-picked without conflicts from the following upstream commit. + +commit d46136bb59c46609ee8050636f0681f2831d2225 +Author: Anton Blanchard +Date: Fri Jun 10 15:24:30 2016 +1000 + + depmod: Ignore PowerPC64 ABIv2 .TOC. symbol + + The .TOC. symbol on the PowerPC64 ABIv2 identifies the GOT + pointer, similar to how other architectures use _GLOBAL_OFFSET_TABLE_. + + This is not a symbol that needs relocation, and should be ignored + by depmod. + +Signed-off-by: Tony Camuso +--- + tools/depmod.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 8d5c671..7b95832 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -2149,6 +2149,8 @@ static void depmod_add_fake_syms(struct depmod *depmod) + depmod_symbol_add(depmod, "__this_module", true, 0, NULL); + /* On S390, this is faked up too */ + depmod_symbol_add(depmod, "_GLOBAL_OFFSET_TABLE_", true, 0, NULL); ++ /* On PowerPC64 ABIv2, .TOC. is more or less _GLOBAL_OFFSET_TABLE_ */ ++ depmod_symbol_add(depmod, "TOC.", true, 0, NULL); + } + + static int depmod_load_symvers(struct depmod *depmod, const char *filename) +-- +1.8.3.1 + diff --git a/SOURCES/kmod-20-9.el7-0003-libkmod-Handle-long-lines-in-proc-modules.patch b/SOURCES/kmod-20-9.el7-0003-libkmod-Handle-long-lines-in-proc-modules.patch new file mode 100644 index 0000000..7d41e1a --- /dev/null +++ b/SOURCES/kmod-20-9.el7-0003-libkmod-Handle-long-lines-in-proc-modules.patch @@ -0,0 +1,89 @@ +From 22dadafa9fa961fa70cc616679b8b24689382348 Mon Sep 17 00:00:00 2001 +From: Tony Camuso +Date: Fri, 24 Jun 2016 12:38:52 -0400 +Subject: [RHEL-7.3 PATCH 3/3] libkmod: Handle long lines in /proc/modules + +Cherry-picked without conflicts from the following upstream commit. + +commit 2206d7f763a1c9cf88f77d0ab19e410d17749361 +Author: Michal Marek +Date: Fri Jun 17 16:04:15 2016 +0200 + + libkmod: Handle long lines in /proc/modules + + kmod_module_new_from_loaded() calls fgets with a 4k buffer. When a + module such as usbcore is used by too many modules, the rest of the line + is considered a beginning of another lines and we eventually get errors + like these from lsmod: + + libkmod: kmod_module_get_holders: could not open '/sys/module/100,/holders': No such file or directory + + together with bogus entries in the output. In kmod_module_get_size, the + problem does not affect functionality, but the line numbers in error + messages will be wrong. + + Signed-off-by: Michal Marek + +Signed-off-by: Tony Camuso +--- + libkmod/libkmod-module.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c +index 366308f..47bb880 100644 +--- a/libkmod/libkmod-module.c ++++ b/libkmod/libkmod-module.c +@@ -1660,13 +1660,14 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx, + struct kmod_module *m; + struct kmod_list *node; + int err; ++ size_t len = strlen(line); + char *saveptr, *name = strtok_r(line, " \t", &saveptr); + + err = kmod_module_new_from_name(ctx, name, &m); + if (err < 0) { + ERR(ctx, "could not get module from name '%s': %s\n", + name, strerror(-err)); +- continue; ++ goto eat_line; + } + + node = kmod_list_append(l, m); +@@ -1676,6 +1677,9 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx, + ERR(ctx, "out of memory\n"); + kmod_module_unref(m); + } ++eat_line: ++ while (line[len - 1] != '\n' && fgets(line, sizeof(line), fp)) ++ len = strlen(line); + } + + fclose(fp); +@@ -1825,12 +1829,13 @@ KMOD_EXPORT long kmod_module_get_size(const struct kmod_module *mod) + } + + while (fgets(line, sizeof(line), fp)) { ++ size_t len = strlen(line); + char *saveptr, *endptr, *tok = strtok_r(line, " \t", &saveptr); + long value; + + lineno++; + if (tok == NULL || !streq(tok, mod->name)) +- continue; ++ goto eat_line; + + tok = strtok_r(NULL, " \t", &saveptr); + if (tok == NULL) { +@@ -1848,6 +1853,9 @@ KMOD_EXPORT long kmod_module_get_size(const struct kmod_module *mod) + + size = value; + break; ++eat_line: ++ while (line[len - 1] != '\n' && fgets(line, sizeof(line), fp)) ++ len = strlen(line); + } + fclose(fp); + +-- +1.8.3.1 + diff --git a/SPECS/kmod.spec b/SPECS/kmod.spec index bd1148d..74775df 100644 --- a/SPECS/kmod.spec +++ b/SPECS/kmod.spec @@ -1,6 +1,6 @@ Name: kmod Version: 20 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Linux kernel module management utilities Group: System Environment/Kernel @@ -12,6 +12,11 @@ Source2: depmod.conf.dist Exclusiveos: Linux BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +Patch01: kmod-%{version}-%{release}-0001-depmod-Don-t-fall-back-to-uname-on-bad-version.patch +Patch02: kmod-%{version}-%{release}-0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol.patch +Patch03: kmod-%{version}-%{release}-0003-libkmod-Handle-long-lines-in-proc-modules.patch + BuildRequires: chrpath BuildRequires: zlib-devel BuildRequires: xz-devel @@ -55,6 +60,9 @@ applications that wish to load or unload Linux kernel modules. %prep %setup -q +%patch01 -p1 -b .0001-depmod-Don-t-fall-back-to-uname-on-bad-version +%patch02 -p1 -b .0002-depmod-Ignore-PowerPC64-ABIv2-.TOC.-symbol +%patch03 -p1 -b .0003-libkmod-Handle-long-lines-in-proc-modules %build export V=1 @@ -120,9 +128,20 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf %{_libdir}/libkmod.so %changelog -* Tue Aug 30 2016 Tony Camuso - 20-8 -- Patch weak-modules to correctly handle powerpc TOC. symbol - Resolves: rhbz#1367662 +* Fri Sep 2 2016 Tony Camuso - 20-9 +- Must be bumped to 20-9 due to changes and version bumps in the + 7.2-z stream. + Resolves: rhbz#1320204 + +* Sat Jun 25 2016 Tony Camuso - 20-7 +- Backported some needed fixes. + Resolves: rhbz#1320204 + +* Fri Feb 26 2016 David Shea - 20-6 +- Accept '.' as part of a symbol exported by the kernel + Resolves: rhbz#1283486 +- Check the addon modules of the new kernel for exported symbols + Resolves: rhbz#1296465 * Wed Jun 3 2015 David Shea - 20-5 - Check for changes in non-module files that affect that initramfs @@ -146,7 +165,7 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf - Rebase to kmod-20 Resolves: rhbz#1199646 -* Tue Jan 14 2015 David Shea - 14-10 +* Wed Jan 14 2015 David Shea - 14-10 - Allow module paths to start with /usr Resolves: rhbz#1177266