Create a module for simple module loading tests.
BUG=chromium-os:37353
TEST=daisy build, security_ModuleLocking passes when using "test_module"
Change-Id: I7ac604b614d69c2f18266a2241a660629b418701
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39918
Reviewed-by: Grant Grundler <grundler@chromium.org>
Tested-by: Grant Grundler <grundler@chromium.org>
obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
obj-$(CONFIG_UID16) += uid16.o
obj-$(CONFIG_MODULES) += module.o
+obj-$(CONFIG_TEST_MODULE) += test_module.o
obj-$(CONFIG_KALLSYMS) += kallsyms.o
obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
obj-$(CONFIG_KEXEC) += kexec.o
--- /dev/null
+/*
+ * "hello world" kernel module
+ */
+
+#define pr_fmt(fmt) "test_module: " fmt
+
+#include <linux/module.h>
+
+static int __init test_module_init(void)
+{
+ pr_info("Hello, world\n");
+
+ return 0;
+}
+
+module_init(test_module_init);
+
+static void __exit test_module_exit(void)
+{
+ pr_info("Goodbye\n");
+}
+
+module_exit(test_module_exit);
+
+MODULE_AUTHOR("Kees Cook <keescook@chromium.org>");
+MODULE_LICENSE("GPL");
If unsure, say N.
+config TEST_MODULE
+ tristate "Test module loading with 'hello world' module"
+ depends on m
+ help
+ This builds the "test_module" module that emits "Hello, world"
+ on printk when loaded. It is designed to be used for basic
+ evaluation of the module loading subsystem.
+
source "samples/Kconfig"
source "lib/Kconfig.kgdb"