lkml.org 
[lkml]   [2003]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectmodutils-2.3.15 'insmod'

modutils-2.3.15, and probably later, has a bug that can prevent
modules from being loaded from initrd, this results in not
being able to mount a root file-system. The bug assumes that
malloc() will return a valid pointer when given an allocation
size of zero.

When there are no modules loaded, insmod scans for modules
and allocates data using its xmalloc() based upon the number
of modules found. If the number was 0, it attempts to allocate
0 bytes (0 times the size of a structure). If malloc() returns
NULL (and it can, probably should), xmalloc() will write an
"out of memory" diagnostic and call exit().

The most recent `man` pages that RH 9.0 distributes states that
malloc() can return either NULL of a pointer that is valid for
free(). This, of course, depends upon the 'C' runtime library's
malloc() implementation.

#include <stdio.h>
#include <malloc.h>
int main(void);
int main()
{
printf("%p\n", malloc(0));
return 0;
}
It is likely that malloc(0) returning a valid pointer is a bug
that has prevented this problem from being observed. Such a
bug in malloc() is probably necessary to keep legacy software
running, but new software shouldn't use such atrocious side-effects.
An allocation of zero needs to be discovered and fixed early
in code design.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [from the cache]
©2003-2011 Jasper Spaans