The return of modversions
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.
