diff options
| author | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2003-01-14 02:29:10 -0600 |
|---|---|---|
| committer | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2003-01-14 02:29:10 -0600 |
| commit | 1d411b80ee1849027d56f86fcf057f29eb4dbe0f (patch) | |
| tree | fa2fc70327b82592a6456f76093c2e3cd7fdc93d /init | |
| parent | 9552d6bcc66126252565555d137ff5e5e45cb959 (diff) | |
Module Sanity Check
This patch, based on Rusty's implementation, adds a special section
to vmlinux and all modules, which contain the kernel version
string, values of some particularly important config options
(SMP,preempt,proc family) and the gcc version.
When inserting a module, the version string is checked against the
kernel version string and loading is rejected if they don't match.
The version string is actually added to the modules during the
final .ko generation, so that a changed version string does only
cause relinking, not recompilation, which is a major performance
improvement over the old 2.4 way of doing things.
Diffstat (limited to 'init')
| -rw-r--r-- | init/Makefile | 3 | ||||
| -rw-r--r-- | init/vermagic.c | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/init/Makefile b/init/Makefile index e8691890702e..f611577436c9 100644 --- a/init/Makefile +++ b/init/Makefile @@ -2,7 +2,8 @@ # Makefile for the linux kernel. # -obj-y := main.o version.o do_mounts.o initramfs.o +obj-y := main.o version.o do_mounts.o initramfs.o +obj-$(CONFIG_MODULES) += vermagic.o # files to be removed upon make clean clean-files := ../include/linux/compile.h diff --git a/init/vermagic.c b/init/vermagic.c new file mode 100644 index 000000000000..0b4a58b70d07 --- /dev/null +++ b/init/vermagic.c @@ -0,0 +1,22 @@ +#include <linux/version.h> +#include <linux/module.h> + +/* Simply sanity version stamp for modules. */ +#ifdef CONFIG_SMP +#define MODULE_VERMAGIC_SMP "SMP " +#else +#define MODULE_VERMAGIC_SMP "" +#endif +#ifdef CONFIG_PREEMPT +#define MODULE_VERMAGIC_PREEMPT "preempt " +#else +#define MODULE_VERMAGIC_PREEMPT "" +#endif +#ifndef MODULE_ARCH_VERMAGIC +#define MODULE_ARCH_VERMAGIC "" +#endif + +const char vermagic[] __attribute__((section("__vermagic"))) = + UTS_RELEASE " " + MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT MODULE_ARCH_VERMAGIC + "gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__); |
