OSDN Git Service

lkdtm: Split WARNING into separate tests
authorKees Cook <keescook@chromium.org>
Mon, 19 Aug 2019 17:24:52 +0000 (10:24 -0700)
committerKees Cook <keescook@chromium.org>
Mon, 19 Aug 2019 18:13:21 +0000 (11:13 -0700)
There are three paths through the kernel code exception logging:

- BUG (no configurable printk message)
- WARN_ON (no configurable printk message)
- WARN (configurable printk message)

LKDTM was not testing WARN_ON(). This is needed to evaluate the placement
of the "cut here" line, which needs special handling in each of the
three exceptions (and between architectures that implement instruction
exceptions to implement the code exceptions).

Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/misc/lkdtm/bugs.c
drivers/misc/lkdtm/core.c
drivers/misc/lkdtm/lkdtm.h

index 1606658..98fad79 100644 (file)
@@ -75,7 +75,12 @@ static int warn_counter;
 
 void lkdtm_WARNING(void)
 {
-       WARN(1, "Warning message trigger count: %d\n", warn_counter++);
+       WARN_ON(++warn_counter);
+}
+
+void lkdtm_WARNING_MESSAGE(void)
+{
+       WARN(1, "Warning message trigger count: %d\n", ++warn_counter);
 }
 
 void lkdtm_EXCEPTION(void)
index 4213619..cbc4c90 100644 (file)
@@ -104,6 +104,7 @@ static const struct crashtype crashtypes[] = {
        CRASHTYPE(PANIC),
        CRASHTYPE(BUG),
        CRASHTYPE(WARNING),
+       CRASHTYPE(WARNING_MESSAGE),
        CRASHTYPE(EXCEPTION),
        CRASHTYPE(LOOP),
        CRASHTYPE(EXHAUST_STACK),
index 8a25afb..ab446e0 100644 (file)
@@ -11,6 +11,7 @@ void __init lkdtm_bugs_init(int *recur_param);
 void lkdtm_PANIC(void);
 void lkdtm_BUG(void);
 void lkdtm_WARNING(void);
+void lkdtm_WARNING_MESSAGE(void);
 void lkdtm_EXCEPTION(void);
 void lkdtm_LOOP(void);
 void lkdtm_EXHAUST_STACK(void);