From 532e2b8a5a02a443b9772725567c32546053fb65 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sep 05 2017 07:19:04 +0000 Subject: import kmod-20-15.el7_4.2 --- diff --git a/SOURCES/kmod-0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU.patch b/SOURCES/kmod-0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU.patch new file mode 100644 index 0000000..4e3be9b --- /dev/null +++ b/SOURCES/kmod-0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU.patch @@ -0,0 +1,93 @@ +From 1e48901166efd65c574de9f6a2b7139721b72623 Mon Sep 17 00:00:00 2001 +From: Yauheni Kaliuta +Date: Wed, 19 Jul 2017 17:56:49 +0300 +Subject: [PATCH] libkmod-elf: resolve CRC if module is built with + MODULE_REL_CRCS + +Normally exported symbol's crc is stored as absolute (SHN_ABS) +value of special named symbol __crc_. + +When the kernel and modules are built with the config option +CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section +and the __crc_ symbols values are offsets in the +section. See patch description of the commit: + +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3 + +Add kmod support of this configuration. + +Signed-off-by: Yauheni Kaliuta +--- + libkmod/libkmod-elf.c | 30 +++++++++++++++++++++++++++++- + 1 file changed, 29 insertions(+), 1 deletion(-) + +diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c +index 90da89aebbaf..ef4a8a3142a1 100644 +--- a/libkmod/libkmod-elf.c ++++ b/libkmod/libkmod-elf.c +@@ -747,6 +747,31 @@ static inline uint8_t kmod_symbol_bind_from_elf(uint8_t elf_value) + } + } + ++static uint64_t kmod_elf_resolve_crc(const struct kmod_elf *elf, uint64_t crc, uint16_t shndx) ++{ ++ int err; ++ uint64_t off, size; ++ uint32_t nameoff; ++ ++ if (shndx == SHN_ABS || shndx == SHN_UNDEF) ++ return crc; ++ ++ err = elf_get_section_info(elf, shndx, &off, &size, &nameoff); ++ if (err < 0) { ++ ELFDBG("Cound not find section index %"PRIu16" for crc", shndx); ++ return (uint64_t)-1; ++ } ++ ++ if (crc > (size - sizeof(uint32_t))) { ++ ELFDBG("CRC offset %"PRIu64" is too big, section %"PRIu16" size is %"PRIu64"\n", ++ crc, shndx, size); ++ return (uint64_t)-1; ++ } ++ ++ crc = elf_get_uint(elf, off + crc, sizeof(uint32_t)); ++ return crc; ++} ++ + /* array will be allocated with strings in a single malloc, just free *array */ + int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **array) + { +@@ -830,6 +855,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar + uint32_t name_off; + uint64_t crc; + uint8_t info, bind; ++ uint16_t shndx; + + #define READV(field) \ + elf_get_uint(elf, sym_off + offsetof(typeof(*s), field),\ +@@ -839,11 +865,13 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar + name_off = READV(st_name); + crc = READV(st_value); + info = READV(st_info); ++ shndx = READV(st_shndx); + } else { + Elf64_Sym *s; + name_off = READV(st_name); + crc = READV(st_value); + info = READV(st_info); ++ shndx = READV(st_shndx); + } + #undef READV + name = elf_get_mem(elf, str_off + name_off); +@@ -856,7 +884,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar + else + bind = ELF64_ST_BIND(info); + +- a[count].crc = crc; ++ a[count].crc = kmod_elf_resolve_crc(elf, crc, shndx); + a[count].bind = kmod_symbol_bind_from_elf(bind); + a[count].symbol = itr; + slen = strlen(name); +-- +2.14.0.rc0 + diff --git a/SOURCES/weak-modules b/SOURCES/weak-modules index e5ef982..65eea86 100644 --- a/SOURCES/weak-modules +++ b/SOURCES/weak-modules @@ -557,7 +557,10 @@ validate_weak_links() { # again $tmp because of subshell, see read_modules_list() comment # create incompatibility report by depmod - /sbin/depmod $basedir -aeE $tmpdir/symvers-$krel -e $krel >$tmp 2>&1 + # Shorcut if depmod finds a lot of incompatible modules elsewhere, + # we care only about weak-updates + /sbin/depmod $basedir -aeE $tmpdir/symvers-$krel $krel 2>&1 | \ + grep "lib/modules/.*/weak-updates" 2>/dev/null >$tmp # parse it into symbols[] associative array in form a-la # symbols["/path/to/the/module"]="list of bad symbols" while read line; do diff --git a/SPECS/kmod.spec b/SPECS/kmod.spec index fa99462..d8069ad 100644 --- a/SPECS/kmod.spec +++ b/SPECS/kmod.spec @@ -1,6 +1,6 @@ Name: kmod Version: 20 -Release: 15%{?dist}.1 +Release: 15%{?dist}.2 Summary: Linux kernel module management utilities Group: System Environment/Kernel @@ -16,6 +16,7 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) Patch01: kmod-0001-depmod-Don-t-fall-back-to-uname-on-bad-version.patch 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 BuildRequires: chrpath BuildRequires: zlib-devel @@ -63,6 +64,7 @@ applications that wish to load or unload Linux kernel modules. %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 +%patch04 -p1 -b .0004-libkmod-elf-resolve-CRC-if-module-is-built-with-MODU %build export V=1 @@ -128,6 +130,11 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf %{_libdir}/libkmod.so %changelog +* Thu Aug 17 2017 Yauheni Kaliuta - 20-15.el7_4.2 +- libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS. +- weak-modules: process only weak-updates related depmod output. + Resolves: rhbz#1482385 + * Wed Jul 12 2017 Yauheni Kaliuta - 20-15.el7_4.1 - weak-modules: fallback weak-modules state if incompatible installed Resolves: rhbz#1469990