Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593615

[PATCH 5/6] notifiers: Use CHECK_DATA_CORRUPTION() on checks

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject [PATCH 5/6] notifiers: Use CHECK_DATA_CORRUPTION() on checks
Date 2017-03-06 20:20 +0100
Message-ID <ti6kN-4hd-11@gated-at.bofh.it> (permalink)
References <ti6kN-4hd-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When performing notifier function pointer sanity checking, allow
CONFIG_BUG_ON_DATA_CORRUPTION to upgrade from a WARN to a BUG.
Additionally enables CONFIG_DEBUG_NOTIFIERS when selecting
CONFIG_BUG_ON_DATA_CORRUPTION.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 kernel/notifier.c | 5 +++--
 lib/Kconfig.debug | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 6196af8a8223..58cc14958d92 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -84,8 +84,9 @@ static int notifier_call_chain(struct notifier_block **nl,
 		next_nb = rcu_dereference_raw(nb->next);
 
 #ifdef CONFIG_DEBUG_NOTIFIERS
-		if (unlikely(!func_ptr_is_kernel_text(nb->notifier_call))) {
-			WARN(1, "Invalid notifier called!");
+		if (CHECK_DATA_CORRUPTION(
+				!func_ptr_is_kernel_text(nb->notifier_call),
+				"Invalid notifier called!")) {
 			nb = next_nb;
 			continue;
 		}
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 42c61cfe7d19..70e9f2c1bb30 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1277,7 +1277,7 @@ config DEBUG_SG
 
 config DEBUG_NOTIFIERS
 	bool "Debug notifier call chains"
-	depends on DEBUG_KERNEL
+	depends on DEBUG_KERNEL || BUG_ON_DATA_CORRUPTION
 	help
 	  Enable this to turn on sanity checking for notifier call chains.
 	  This is most useful for kernel developers to make sure that
@@ -1995,6 +1995,7 @@ config BUG_ON_DATA_CORRUPTION
 	bool "Trigger a BUG when data corruption is detected"
 	select DEBUG_CREDENTIALS
 	select DEBUG_LIST
+	select DEBUG_NOTIFIERS
 	select DEBUG_SG
 	help
 	  This option enables several inexpensive data corruption checks.
-- 
2.7.4

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] bug: further enhance use of BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 4/6] bug: Enable DEBUG_SG under BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 5/6] notifiers: Use CHECK_DATA_CORRUPTION() on checks Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 3/6] bug: Enable DEBUG_CREDENTIALS under BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 1/6] bug: Clarify help text for BUG_ON_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 2/6] bug: Improve unlikely() in data corruption check Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100
  [PATCH 6/6] refcount: Check bad states with CHECK_DATA_CORRUPTION Kees Cook <keescook@chromium.org> - 2017-03-06 20:20 +0100

csiph-web