From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752092AbdBEPlO (ORCPT ); Sun, 5 Feb 2017 10:41:14 -0500 Received: from merlin.infradead.org ([205.233.59.134]:49118 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344AbdBEPlN (ORCPT ); Sun, 5 Feb 2017 10:41:13 -0500 Date: Sun, 5 Feb 2017 16:40:46 +0100 From: Peter Zijlstra To: Kees Cook Cc: elena.reshetova@intel.com, gregkh@linuxfoundation.org, arnd@arndb.de, tglx@linutronix.de, mingo@kernel.org, h.peter.anvin@intel.com, will.deacon@arm.com, dwindsor@gmail.com, Hans Liljestrand , dhowells@redhat.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Message-ID: <20170205154046.GF6515@twins.programming.kicks-ass.net> References: <1486164412-7338-1-git-send-email-keescook@chromium.org> <1486164412-7338-5-git-send-email-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1486164412-7338-5-git-send-email-keescook@chromium.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2017 at 03:26:52PM -0800, Kees Cook wrote: > This converts from WARN_ON() to CHECK_DATA_CORRUPTION() in the > CONFIG_DEBUG_REFCOUNT case. Additionally moves refcount_t sanity check > conditionals into regular function flow. Since CHECK_DATA_CORRUPTION() > is marked __much_check, we override few cases where the failure has > already been handled but we want to explicitly report it. > > Signed-off-by: Kees Cook > --- > include/linux/refcount.h | 35 ++++++++++++++++++++++------------- > lib/Kconfig.debug | 2 ++ > 2 files changed, 24 insertions(+), 13 deletions(-) > > diff --git a/include/linux/refcount.h b/include/linux/refcount.h > index 5b89cad62237..ef32910c7dd8 100644 > --- a/include/linux/refcount.h > +++ b/include/linux/refcount.h > @@ -43,10 +43,10 @@ > #include > > #if CONFIG_DEBUG_REFCOUNT > -#define REFCOUNT_WARN(cond, str) WARN_ON(cond) > +#define REFCOUNT_CHECK(cond, str) CHECK_DATA_CORRUPTION(cond, str) OK, so that goes back to a full WARN() which will make the generated code gigantic due to the whole printk() trainwreck :/ From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 5 Feb 2017 16:40:46 +0100 From: Peter Zijlstra Message-ID: <20170205154046.GF6515@twins.programming.kicks-ass.net> References: <1486164412-7338-1-git-send-email-keescook@chromium.org> <1486164412-7338-5-git-send-email-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1486164412-7338-5-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION To: Kees Cook Cc: elena.reshetova@intel.com, gregkh@linuxfoundation.org, arnd@arndb.de, tglx@linutronix.de, mingo@kernel.org, h.peter.anvin@intel.com, will.deacon@arm.com, dwindsor@gmail.com, Hans Liljestrand , dhowells@redhat.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com List-ID: On Fri, Feb 03, 2017 at 03:26:52PM -0800, Kees Cook wrote: > This converts from WARN_ON() to CHECK_DATA_CORRUPTION() in the > CONFIG_DEBUG_REFCOUNT case. Additionally moves refcount_t sanity check > conditionals into regular function flow. Since CHECK_DATA_CORRUPTION() > is marked __much_check, we override few cases where the failure has > already been handled but we want to explicitly report it. > > Signed-off-by: Kees Cook > --- > include/linux/refcount.h | 35 ++++++++++++++++++++++------------- > lib/Kconfig.debug | 2 ++ > 2 files changed, 24 insertions(+), 13 deletions(-) > > diff --git a/include/linux/refcount.h b/include/linux/refcount.h > index 5b89cad62237..ef32910c7dd8 100644 > --- a/include/linux/refcount.h > +++ b/include/linux/refcount.h > @@ -43,10 +43,10 @@ > #include > > #if CONFIG_DEBUG_REFCOUNT > -#define REFCOUNT_WARN(cond, str) WARN_ON(cond) > +#define REFCOUNT_CHECK(cond, str) CHECK_DATA_CORRUPTION(cond, str) OK, so that goes back to a full WARN() which will make the generated code gigantic due to the whole printk() trainwreck :/