Commit d8e988b6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'char-misc-5.15-rc1-lkdtm' of...

Merge tag 'char-misc-5.15-rc1-lkdtm' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull misc driver fix from Greg KH:
 "Here is a single patch for 5.15-rc1, for the lkdtm misc driver.

  It resolves a build issue that many people were hitting with your
  current tree, and Kees and others felt would be good to get merged
  before -rc1 comes out, to prevent them from having to constantly hit
  it as many development trees restart on -rc1, not older -rc releases.

  It has NOT been in linux-next, but has passed 0-day testing and looks
  'obviously correct' when reviewing it locally :)"

* tag 'char-misc-5.15-rc1-lkdtm' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  lkdtm: Use init_uts_ns.name instead of macros
parents 1791596b 3a3a11e6
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/utsname.h>
#define DEFAULT_COUNT 10 #define DEFAULT_COUNT 10
...@@ -210,6 +211,8 @@ module_param(cpoint_count, int, 0644); ...@@ -210,6 +211,8 @@ module_param(cpoint_count, int, 0644);
MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\ MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
"crash point is to be hit to trigger action"); "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 */ /* Return the crashtype number or NULL if the name is invalid */
static const struct crashtype *find_crashtype(const char *name) static const struct crashtype *find_crashtype(const char *name)
...@@ -490,6 +493,11 @@ static int __init lkdtm_module_init(void) ...@@ -490,6 +493,11 @@ static int __init lkdtm_module_init(void)
crash_count = cpoint_count; crash_count = cpoint_count;
#endif #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. */ /* Handle test-specific initialization. */
lkdtm_bugs_init(&recur_count); lkdtm_bugs_init(&recur_count);
lkdtm_perms_init(); lkdtm_perms_init();
...@@ -538,6 +546,8 @@ static void __exit lkdtm_module_exit(void) ...@@ -538,6 +546,8 @@ static void __exit lkdtm_module_exit(void)
if (lkdtm_kprobe != NULL) if (lkdtm_kprobe != NULL)
unregister_kprobe(lkdtm_kprobe); unregister_kprobe(lkdtm_kprobe);
kfree(lkdtm_kernel_info);
pr_info("Crash point unregistered\n"); pr_info("Crash point unregistered\n");
} }
......
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
#define pr_fmt(fmt) "lkdtm: " fmt #define pr_fmt(fmt) "lkdtm: " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <generated/compile.h>
#include <generated/utsrelease.h>
#define LKDTM_KERNEL "kernel (" UTS_RELEASE " " UTS_MACHINE ")" extern char *lkdtm_kernel_info;
#define pr_expected_config(kconfig) \ #define pr_expected_config(kconfig) \
{ \ { \
if (IS_ENABLED(kconfig)) \ if (IS_ENABLED(kconfig)) \
pr_err("Unexpected! This " LKDTM_KERNEL " was built with " #kconfig "=y\n"); \ pr_err("Unexpected! This %s was built with " #kconfig "=y\n", \
lkdtm_kernel_info); \
else \ else \
pr_warn("This is probably expected, since this " LKDTM_KERNEL " was built *without* " #kconfig "=y\n"); \ pr_warn("This is probably expected, since this %s was built *without* " #kconfig "=y\n", \
lkdtm_kernel_info); \
} }
#ifndef MODULE #ifndef MODULE
...@@ -25,24 +25,30 @@ int lkdtm_check_bool_cmdline(const char *param); ...@@ -25,24 +25,30 @@ int lkdtm_check_bool_cmdline(const char *param);
if (IS_ENABLED(kconfig)) { \ if (IS_ENABLED(kconfig)) { \
switch (lkdtm_check_bool_cmdline(param)) { \ switch (lkdtm_check_bool_cmdline(param)) { \
case 0: \ case 0: \
pr_warn("This is probably expected, since this " LKDTM_KERNEL " was built with " #kconfig "=y but booted with '" param "=N'\n"); \ pr_warn("This is probably expected, since this %s was built with " #kconfig "=y but booted with '" param "=N'\n", \
lkdtm_kernel_info); \
break; \ break; \
case 1: \ case 1: \
pr_err("Unexpected! This " LKDTM_KERNEL " was built with " #kconfig "=y and booted with '" param "=Y'\n"); \ pr_err("Unexpected! This %s was built with " #kconfig "=y and booted with '" param "=Y'\n", \
lkdtm_kernel_info); \
break; \ break; \
default: \ default: \
pr_err("Unexpected! This " LKDTM_KERNEL " was built with " #kconfig "=y (and booted without '" param "' specified)\n"); \ pr_err("Unexpected! This %s was built with " #kconfig "=y (and booted without '" param "' specified)\n", \
lkdtm_kernel_info); \
} \ } \
} else { \ } else { \
switch (lkdtm_check_bool_cmdline(param)) { \ switch (lkdtm_check_bool_cmdline(param)) { \
case 0: \ case 0: \
pr_warn("This is probably expected, as this " LKDTM_KERNEL " was built *without* " #kconfig "=y and booted with '" param "=N'\n"); \ pr_warn("This is probably expected, as this %s was built *without* " #kconfig "=y and booted with '" param "=N'\n", \
lkdtm_kernel_info); \
break; \ break; \
case 1: \ case 1: \
pr_err("Unexpected! This " LKDTM_KERNEL " was built *without* " #kconfig "=y but booted with '" param "=Y'\n"); \ pr_err("Unexpected! This %s was built *without* " #kconfig "=y but booted with '" param "=Y'\n", \
lkdtm_kernel_info); \
break; \ break; \
default: \ default: \
pr_err("This is probably expected, since this " LKDTM_KERNEL " was built *without* " #kconfig "=y (and booted without '" param "' specified)\n"); \ pr_err("This is probably expected, since this %s was built *without* " #kconfig "=y (and booted without '" param "' specified)\n", \
lkdtm_kernel_info); \
break; \ break; \
} \ } \
} \ } \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment