1 /* SPDX-License-Identifier: GPL-2.0 */
5 #define pr_fmt(fmt) "lkdtm: " fmt
7 #include <linux/kernel.h>
9 extern char *lkdtm_kernel_info
;
11 #define pr_expected_config(kconfig) \
13 if (IS_ENABLED(kconfig)) \
14 pr_err("Unexpected! This %s was built with " #kconfig "=y\n", \
17 pr_warn("This is probably expected, since this %s was built *without* " #kconfig "=y\n", \
22 int lkdtm_check_bool_cmdline(const char *param
);
23 #define pr_expected_config_param(kconfig, param) \
25 if (IS_ENABLED(kconfig)) { \
26 switch (lkdtm_check_bool_cmdline(param)) { \
28 pr_warn("This is probably expected, since this %s was built with " #kconfig "=y but booted with '" param "=N'\n", \
32 pr_err("Unexpected! This %s was built with " #kconfig "=y and booted with '" param "=Y'\n", \
36 pr_err("Unexpected! This %s was built with " #kconfig "=y (and booted without '" param "' specified)\n", \
40 switch (lkdtm_check_bool_cmdline(param)) { \
42 pr_warn("This is probably expected, as this %s was built *without* " #kconfig "=y and booted with '" param "=N'\n", \
46 pr_err("Unexpected! This %s was built *without* " #kconfig "=y but booted with '" param "=Y'\n", \
50 pr_err("This is probably expected, since this %s was built *without* " #kconfig "=y (and booted without '" param "' specified)\n", \
57 #define pr_expected_config_param(kconfig, param) pr_expected_config(kconfig)
66 #define CRASHTYPE(_name) \
68 .name = __stringify(_name), \
69 .func = lkdtm_ ## _name, \
72 /* Category's collection of crashtypes. */
73 struct crashtype_category
{
74 struct crashtype
*crashtypes
;
78 /* Each category's crashtypes list. */
79 extern struct crashtype_category bugs_crashtypes
;
80 extern struct crashtype_category heap_crashtypes
;
81 extern struct crashtype_category perms_crashtypes
;
82 extern struct crashtype_category refcount_crashtypes
;
83 extern struct crashtype_category usercopy_crashtypes
;
84 extern struct crashtype_category stackleak_crashtypes
;
85 extern struct crashtype_category cfi_crashtypes
;
86 extern struct crashtype_category fortify_crashtypes
;
87 extern struct crashtype_category powerpc_crashtypes
;
89 /* Each category's init/exit routines. */
90 void __init
lkdtm_bugs_init(int *recur_param
);
91 void __init
lkdtm_heap_init(void);
92 void __exit
lkdtm_heap_exit(void);
93 void __init
lkdtm_perms_init(void);
94 void __init
lkdtm_usercopy_init(void);
95 void __exit
lkdtm_usercopy_exit(void);
97 /* Special declaration for function-in-rodata. */
98 void lkdtm_rodata_do_nothing(void);