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 1606658b9b7e35ce307c25d3dcf770ef3620f6d8..98fad790959220f300949a4b88ddb9a2e9cc4656 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 42136196681eb38ffb003432e0d15a882f771f64..cbc4c9045a990f49a5b357e29192aa8a29f9ca28 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 8a25afbdf95491609def49f2b6e31e8c045ebb1d..ab446e0bde975ff6a819cc6db6c2f150485342b3 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);