From patchwork Mon Mar 6 19:09:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9607359 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 A7C09601D2 for ; Mon, 6 Mar 2017 19:10:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1B112711E for ; Mon, 6 Mar 2017 19:10:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A686B27B2F; Mon, 6 Mar 2017 19:10:35 +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 E3EA726BE9 for ; Mon, 6 Mar 2017 19:10:34 +0000 (UTC) Received: (qmail 9483 invoked by uid 550); 6 Mar 2017 19:10:10 -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 9381 invoked from network); 6 Mar 2017 19:10:08 -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=Wb1uO1EVHGvIaHVyn+xRiuMxdcmjFpCIT+p0gFDmBFQ=; b=b7dufhn32b5JVyjf7IsS9BceQ9lwPzJUyVmX/KxduxSRk6utIVUh5Vb8q/vyTdDdWv EBQeqrrgfIgSsF1/v5YTMqTtn49ynR6FiND4x+KnPEKWcUVW/M4oGS4IkiHLwa3ZXIru ouBnh77y3DHeMLKQKO9pau0SFAFyFe6RiqziQ= 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=Wb1uO1EVHGvIaHVyn+xRiuMxdcmjFpCIT+p0gFDmBFQ=; b=TWdh4CEXjGzaQ1WXFepcBIMa7fzy88F/gQf0/EjrvO/os69kxWghO/T3GyeCh1Xjsv IH2RG7IXttLndSufYuNQYVc51VklP9YeHNg8+H5qqvyMpH2vTMXmC2+y2t4y7D/e6Jfs Rnwv+61ltS5q2qwdTZVaUieymycEeCdriGTWwy4TGjGp7hmI8rzLfBLZodYPB2bTeRTr Bs3NCu2P2pwTAVvJlvg7J+/qoK3XzSqysk7iFzHunTUPZ4X7/u8l5PovbF/Fnn3hjsRb Z0mis4QsHNd54OE+X2yZTvFHCbygfBixcTZxosHFttaNZHdOB2LCC/Z6RVb6tl5wha/N Qz/w== X-Gm-Message-State: AMke39ka3Kt1Zn1uLtTU7B8M36GtIDJcaBTXQVGcyL4StEWbweIBMCR4RRSFAgGeHEMjrxRg X-Received: by 10.84.168.4 with SMTP id e4mr28861111plb.138.1488827396545; Mon, 06 Mar 2017 11:09:56 -0800 (PST) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Andrew Morton , Rik van Riel , "Paul E. McKenney" , Jakub Kicinski , Viresh Kumar , Ingo Molnar , Thomas Gleixner , Dmitry Vyukov , Olof Johansson , Peter Zijlstra , Josh Poimboeuf , linux-kernel@vger.kernel.org Date: Mon, 6 Mar 2017 11:09:45 -0800 Message-Id: <1488827386-87193-6-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488827386-87193-1-git-send-email-keescook@chromium.org> References: <1488827386-87193-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 5/6] 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 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.