Bug 200

Summary: module-init-tools-cross version 3.12 segfaults in depmod.
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Mark Hatle <mark.hatle>
Component: coreAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: Undecided CC: kevin.tian, meta.mr.watcher, meta.watcher, sgw
Version: 0.9   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Mark Hatle 2010-08-05 22:05:00 UTC
When using depmod on a RHEL 5 system, module-init-tools-cross can segfault.

Reproducing this bug is dependent upon the memory layout of the host, so it may be difficult to reproduce.

For the full bug report upstream see: http://article.gmane.org/gmane.linux.kernel.modules/478

(a bug will also be filed upstream.)

Important bits quoted below:

I was able to track down the problem to the output_pci_table function.

The pci_table has a bad address in it.  Tracing things 
back in elfops_core.c:fetch_tables, the memset of the tables is never done 
because strings and syms are both empty.

Tracing back further to depmod.c:grab_module, it appears that the new = 
malloc(...) setups up things, but never clears the memory that was just allocated.

As a quick hack I added a memset to clear memory:

  static struct module *grab_module(const char *dirname, const char *filename)
  {
          struct module *new;

          new = NOFAIL(malloc(sizeof(*new)
                              + strlen(dirname?:"") + 1 + strlen(filename) + 1));
+        memset(new, 0x00, sizeof(*new) + strlen(dirname?:"") + 1 + 
strlen(filename) + 1);
          if (dirname)
                  sprintf(new->pathname, "%s/%s", dirname, filename);
          else

Things now appear to be working as expected, no segfaults, no unusual behavior.
Comment 1 Mark Hatle 2010-08-05 22:10:45 UTC
Filed with the upstream maintainer, see:

https://bugzilla.kernel.org/show_bug.cgi?id=16528
Comment 2 Mark Hatle 2010-08-06 07:01:26 UTC
Note:  this was found on a RHEL 5.1 based system.  Running kernel 2.6.18-53.el5PAE and glibc-2.5-18.

I've been able to reproduce the segfault on both 32-bit and 64-bit ia32 systems.
Comment 3 Richard Purdie 2010-08-06 10:38:16 UTC
This should be fixed in f4cb0870acd980a35e6e87b5bcf548a4452fd6a7 as far as Poky goes