summaryrefslogtreecommitdiff
path: root/drivers/misc/lkdtm/core.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-09-02 02:34:06 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-10 18:09:40 +0300
commit3a3a11e6e5a2bc0595c7e36ae33c861c9e8c75b1 (patch)
tree6762298294782347644214de7d90a3a0e913eb1d /drivers/misc/lkdtm/core.c
parentbf9f243f23e6623f310ba03fbb14e10ec3a61290 (diff)
downloadlinux-3a3a11e6e5a2bc0595c7e36ae33c861c9e8c75b1.tar.xz
lkdtm: Use init_uts_ns.name instead of macros
Using generated/compile.h triggered a full LKDTM rebuild with every build. Avoid this by using the exported strings instead. Fixes: b8661450bc7f ("lkdtm: Add kernel version to failure hints") Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20210901233406.2571643-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/lkdtm/core.c')
-rw-r--r--drivers/misc/lkdtm/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
index 95b1c6800a22..fe6fd34b8caf 100644
--- a/drivers/misc/lkdtm/core.c
+++ b/drivers/misc/lkdtm/core.c
@@ -26,6 +26,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
+#include <linux/utsname.h>
#define DEFAULT_COUNT 10
@@ -210,6 +211,8 @@ module_param(cpoint_count, int, 0644);
MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
"crash point is to be hit to trigger action");
+/* For test debug reporting. */
+char *lkdtm_kernel_info;
/* Return the crashtype number or NULL if the name is invalid */
static const struct crashtype *find_crashtype(const char *name)
@@ -490,6 +493,11 @@ static int __init lkdtm_module_init(void)
crash_count = cpoint_count;
#endif
+ /* Common initialization. */
+ lkdtm_kernel_info = kasprintf(GFP_KERNEL, "kernel (%s %s)",
+ init_uts_ns.name.release,
+ init_uts_ns.name.machine);
+
/* Handle test-specific initialization. */
lkdtm_bugs_init(&recur_count);
lkdtm_perms_init();
@@ -538,6 +546,8 @@ static void __exit lkdtm_module_exit(void)
if (lkdtm_kprobe != NULL)
unregister_kprobe(lkdtm_kprobe);
+ kfree(lkdtm_kernel_info);
+
pr_info("Crash point unregistered\n");
}