Modinfo segment fault if failed to open module file.

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Virtualization (RHEV) 3.1
  • Red Hat Enterprise Linux 6
  • Package: module-init-tools

Issue

  • LC not capturing sosreports from every hypervisor
  • modinfo mlx4_ib segment fault
  • Segmentation fault occurs on modinfo when sosreport is running.

Resolution

  • This issue is resolved in module-init-tools-3.9-22.el6 and later.
  • For 6.4.z, install module-init-tools-3.9-21.el6_4 from Errata RHBA-2013:0961 (private bug 972588)

  • As a workaround, when running sosreport, turn off the modinfo report:

# sosreport -k kernel.modinfo=off

Root Cause

When modinfo is unable to find the kernel module file, it attempts to output a warning message in the function grab_module. However, it incorrectly failed to dereference a pointer leading to modinfo hitting a segment fault.

sosreport fails if modinfo fails.

Diagnostic Steps

  • Gather a core file and check for a stack trace with this signature.
Core was generated by `/sbin/modinfo iptable_filter ip_tables nfsd lockd nfs_acl auth_rpcgss exportfs'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000035998480ac in _IO_vfprintf_internal (s=<value optimized out>, format=<value optimized out>, ap=<value optimized out>) at vfprintf.c:1641
1641              process_string_arg (((struct printf_spec *) NULL));
(gdb) bt
#0  0x00000035998480ac in _IO_vfprintf_internal (s=<value optimized out>, format=<value optimized out>, ap=<value optimized out>) at vfprintf.c:1641
#1  0x0000003599901e6c in __vasprintf_chk (result_ptr=0x7fff6f325af8, flags=1, format=0x40e3d0 "modinfo: could not open %s: %s\n", args=0x7fff6f325b20) at vasprintf_chk.c:68
#2  0x000000000040c05e in vasprintf (prefix=0x414306 "ERROR: ", fmt=<value optimized out>, arglist=<value optimized out>) at /usr/include/bits/stdio2.h:199
#3  message (prefix=0x414306 "ERROR: ", fmt=<value optimized out>, arglist=<value optimized out>) at ../logging.c:24
#4  0x000000000040c243 in error (fmt=<value optimized out>) at ../logging.c:56
#5  0x0000000000401805 in grab_module (name=<value optimized out>, kernel=<value optimized out>, basedir=<value optimized out>) at ../modinfo.c:244
#6  0x0000000000401d92 in main (argc=36, argv=<value optimized out>) at ../modinfo.c:305

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.