Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1593448

Summary: [RHEL7] weak-modules doesn't handle compressed modules properly
Product: Red Hat Enterprise Linux 7 Reporter: Frank Hirtz <fhirtz>
Component: kmodAssignee: Yauheni Kaliuta <ykaliuta>
Status: CLOSED ERRATA QA Contact: Ziqian SUN (Zamir) <zsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.5CC: juri, skozina
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 11:35:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Hirtz 2018-06-20 20:50:02 UTC
Description of problem:
The 'weak-modules' script doesn't properly take compressed modules into account in a couple of places. This was discovered when installing a kmod package with a compressed module for a kernel that wasn't installed/compatible with one on the system, but the issue appears to be more general.

<snip>
[fmhirtz@ivanova SPECS]$ rpm -q kernel
kernel-3.10.0-862.3.2.el7.x86_64
[fmhirtz@ivanova SPECS]$ rpm -qa | grep exanic
[fmhirtz@ivanova SPECS]$ sudo rpm -ivh ../RPMS/x86_64/exanic-kmod-3.10.0-862.el7.x86_64-2.1.1-2.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:exanic-kmod-3.10.0-862.el7.x86_64################################# [100%]
Module exanic.ko.xz from kernel 3.10.0-862.el7.x86_64 is compatible with kernel 3.10.0-862.3.2.el7.x86_64
Module exasock.ko.xz from kernel 3.10.0-862.el7.x86_64 is compatible with kernel 3.10.0-862.3.2.el7.x86_64
Skipping depmod for non-installed kernel 3.10.0-862.el7.x86_64
[fmhirtz@ivanova SPECS]$ ls -l /lib/modules/*/weak-updates/
total 0
lrwxrwxrwx. 1 root root 53 Jun 20 16:38 exanic.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exanic.ko.xz
lrwxrwxrwx. 1 root root 54 Jun 20 16:38 exasock.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exasock.ko.xz
[fmhirtz@ivanova SPECS]$ sudo rpm -ivh ../RPMS/x86_64/exanic-kmod-3.10.0-693.11.1.el7.x86_64-2.1.1-2.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:exanic-kmod-3.10.0-693.11.1.el7.x################################# [100%]
weak module for exanic.ko.xz already exists for kernel 3.10.0-862.3.2.el7.x86_64, update case?
weak module for exasock.ko.xz already exists for kernel 3.10.0-862.3.2.el7.x86_64, update case?
Module exasock.ko.xz from kernel 3.10.0-693.11.1.el7.x86_64 is not compatible with kernel 3.10.0-862.3.2.el7.x86_64 in symbols:  __ip_route_output_key_hash
Module exanic.ko.xz from kernel 3.10.0-693.11.1.el7.x86_64 is not compatible with kernel 3.10.0-862.3.2.el7.x86_64 in symbols:  napi_complete_done ktime_get_snapshot
Falling back weak-modules state for kernel 3.10.0-862.3.2.el7.x86_64
Skipping depmod for non-installed kernel 3.10.0-693.11.1.el7.x86_64
/sbin/depmod -ae -F /boot/System.map-3.10.0-862.3.2.el7.x86_64 3.10.0-862.3.2.el7.x86_64
[fmhirtz@ivanova SPECS]$ ls -l /lib/modules/*/weak-updates/
total 0
[fmhirtz@ivanova SPECS]$
</snip>



<patch>
--- /usr/sbin/weak-modules	2018-06-20 16:40:23.510969802 -0400
+++ /usr/sbin/weak-modules.new	2018-06-20 16:40:26.109818658 -0400
@@ -378,7 +378,7 @@
     local dirs="$*"
 
     for dir in $dirs; do
-        find $BASEDIR/lib/modules/$krel/$dir -name '*.ko' 2>/dev/null
+        find $BASEDIR/lib/modules/$krel/$dir -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.gz' 2>/dev/null
     done
 }
 
@@ -389,7 +389,7 @@
     local dirs="$*"
 
     for dir in $dirs; do
-        find $dir -name '*.ko' 2>/dev/null
+        find $dir -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.gz' 2>/dev/null
     done
 }
 
</patch>

With the patch, it appears to work as would be expected:

<with patch>
[fmhirtz@ivanova SPECS]$ sudo cp /usr/sbin/weak-modules.new /usr/sbin/weak-modules
[fmhirtz@ivanova SPECS]$ rpm -q kernel
kernel-3.10.0-862.3.2.el7.x86_64
[fmhirtz@ivanova SPECS]$ rpm -qa | grep exanic
[fmhirtz@ivanova SPECS]$ sudo rpm -ivh ../RPMS/x86_64/exanic-kmod-3.10.0-862.el7.x86_64-2.1.1-2.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:exanic-kmod-3.10.0-862.el7.x86_64################################# [100%]
Module exanic.ko.xz from kernel 3.10.0-862.el7.x86_64 is compatible with kernel 3.10.0-862.3.2.el7.x86_64
Module exasock.ko.xz from kernel 3.10.0-862.el7.x86_64 is compatible with kernel 3.10.0-862.3.2.el7.x86_64
/sbin/depmod -ae -F /boot/System.map-3.10.0-862.3.2.el7.x86_64 3.10.0-862.3.2.el7.x86_64
Skipping depmod for non-installed kernel 3.10.0-862.el7.x86_64
[fmhirtz@ivanova SPECS]$ ls -l /lib/modules/*/weak-updates/
total 0
lrwxrwxrwx. 1 root root 53 Jun 20 16:43 exanic.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exanic.ko.xz
lrwxrwxrwx. 1 root root 54 Jun 20 16:43 exasock.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exasock.ko.xz
[fmhirtz@ivanova SPECS]$ sudo rpm -ivh ../RPMS/x86_64/exanic-kmod-3.10.0-693.11.1.el7.x86_64-2.1.1-2.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:exanic-kmod-3.10.0-693.11.1.el7.x################################# [100%]
weak module for exanic.ko.xz already exists for kernel 3.10.0-862.3.2.el7.x86_64, update case?
weak module for exasock.ko.xz already exists for kernel 3.10.0-862.3.2.el7.x86_64, update case?
Module exasock.ko.xz from kernel 3.10.0-693.11.1.el7.x86_64 is not compatible with kernel 3.10.0-862.3.2.el7.x86_64 in symbols:  __ip_route_output_key_hash
Module exanic.ko.xz from kernel 3.10.0-693.11.1.el7.x86_64 is not compatible with kernel 3.10.0-862.3.2.el7.x86_64 in symbols:  napi_complete_done ktime_get_snapshot
Falling back weak-modules state for kernel 3.10.0-862.3.2.el7.x86_64
Skipping depmod for non-installed kernel 3.10.0-693.11.1.el7.x86_64
/sbin/depmod -ae -F /boot/System.map-3.10.0-862.3.2.el7.x86_64 3.10.0-862.3.2.el7.x86_64
[fmhirtz@ivanova SPECS]$ ls -l /lib/modules/*/weak-updates/
total 0
lrwxrwxrwx. 1 root root 53 Jun 20 16:45 exanic.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exanic.ko.xz
lrwxrwxrwx. 1 root root 54 Jun 20 16:45 exasock.ko.xz -> /lib/modules/3.10.0-862.el7.x86_64/extra/exasock.ko.xz
[fmhirtz@ivanova SPECS]$ 
</with patch>

Version-Release number of selected component (if applicable):
kmod-20-21.el7.x86_64

Comment 2 Yauheni Kaliuta 2018-06-21 07:29:35 UTC
Just a note, it should also check them in initramfs then.

Comment 12 errata-xmlrpc 2018-10-30 11:35:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3255