From patchwork Tue Apr 4 22:12:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9662703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E0556032D for ; Tue, 4 Apr 2017 22:13:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FE7827F94 for ; Tue, 4 Apr 2017 22:13:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0464728587; Tue, 4 Apr 2017 22:13:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 2E42727F94 for ; Tue, 4 Apr 2017 22:13:11 +0000 (UTC) Received: (qmail 26445 invoked by uid 550); 4 Apr 2017 22:12:41 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 26290 invoked from network); 4 Apr 2017 22:12:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v0SYbWufvZ2csW+SaX573SBzzCn6LB65BPDl/SuqVpM=; b=fM66iAIyKNmStWudzmzYGJsHDgJ+LO8F3FbU+HC5QHcOTRbVXPnFN6pX5egGAFQViY m59X611Po4J6c0xqF3jn0ObQ2PTDvpytvV5HeU08oKoyAhXOam0h8m6Y94ZQyXeKWjok BtGlIEZ1uzP4Zfd25wpzZFWgWsuIIKzMhrEKc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v0SYbWufvZ2csW+SaX573SBzzCn6LB65BPDl/SuqVpM=; b=ZNYJ5oR26Dluk1G7T4UlpEH6RCWmvUp7cNYQylIiw1ta71ZjoQFCglW0RYX6+Bl9l2 j+TxJe5dGB9N/YiPOSKbYZ5NYeqRdTybF6fITqJB24/htBIs5crSaN1IcXD6rmRMUcTL mzVh1CGwQV2uUC2X3rc64/o4alf94fxSvihRajZxiyAfHP2ljKr7hDX1ZthasB1cwGdL knR0VnjZM//OEEI9kvdythnhcBCJA+NSe8eURdNM8bNNUzJroRDq/uS8h9D30HRQ1BOt O39LVastJfcj7gJlDdgSJ641TqHTizybsl/9dRIML41LizW5DzA0kjDrL7dWe+bURsHn Mxpg== X-Gm-Message-State: AFeK/H3jhaXSXyOCkMadPYIZhmPTvs+Of4NoUK7jPtpcsJtDbCdHEIorEsRd8H/21PlZ/U8a X-Received: by 10.84.218.68 with SMTP id f4mr31697636plm.146.1491343947105; Tue, 04 Apr 2017 15:12:27 -0700 (PDT) From: Kees Cook To: Ingo Molnar Cc: Kees Cook , Peter Zijlstra , "Paul E. McKenney" , Kalle Valo , Andrew Morton , Rik van Riel , Jakub Kicinski , Viresh Kumar , Andy Shevchenko , Geert Uytterhoeven , Olof Johansson , Chris Wilson , George Spelvin , Thomas Gleixner , Josh Poimboeuf , David Windsor , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Tue, 4 Apr 2017 15:12:17 -0700 Message-Id: <1491343938-75336-7-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491343938-75336-1-git-send-email-keescook@chromium.org> References: <1491343938-75336-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 6/7] notifiers: Use CHECK_DATA_CORRUPTION() on checks X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 45bfc0be38fc..0dc8f6065be8 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1278,7 +1278,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 @@ -1998,6 +1998,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.