The return of modversions
[Posted January 29, 2003 by corbet]
Perhaps the biggest bit of unfinished work with the new kernel module
loader is the module versioning support. Module versioning is an attempt
to make binary loadable modules work with multiple kernel versions. It
works by attaching a checksum to each exported kernel symbol; the checksum
is calculated from the prototype or declaration of the symbol. As long as
the checksums in a module match those in the running kernel, it is assumed
that the module can be safely loaded. Kernel hackers tend not to use
module versioning, which explains why it took so long to get this feature
fixed. Production kernels shipped by distributors need this feature,
however; otherwise it is essentially impossible for vendors to support
binary-only modules.
Kai Germaschewski has posted a modversions
implementation which works with recent 2.5 kernels. The underlying idea is
essentially the same as that found in previous implementations, but the
implementation is entirely different.
The old scheme used the genksyms program to generate the
checksums, and to create a bunch of include files (ending in .ver)
which redefined the exported kernel names to include those checksums. The
effect was to create a bunch of preprocessor definitions like:
#define printk printk_R1b7d4074
(The actual definitions were a little more complicated). Loadable modules
would thus be built to call printk_R1b7d4074() instead of
printk(). The names were stored in that form in the kernel symbol
table, so the insmod program simply needed to look for a direct
match. If the interface had changed, the names would not match, and the
module would refuse to load.
The new implementation does away with the include files. It does
still use genksyms, but the output is reprocessed into a set of
structure declarations. One structure (containing the symbol name and its
checksum) is created for each symbol used by the module; the array of
structures is then linked into the module in a special section. When a
module is loaded into the kernel, the checksums are used to verify
compatibility, and the special section can be discarded. Among other
things, this approach makes it easier to force the loading of a module with
mismatched symbols, should anybody be unwise enough to attempt such a thing.
(
Log in to post comments)