From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756108AbdEROMQ (ORCPT ); Thu, 18 May 2017 10:12:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45736 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754754AbdEROMN (ORCPT ); Thu, 18 May 2017 10:12:13 -0400 Date: Thu, 18 May 2017 16:12:03 +0200 From: Greg KH To: Petr Mladek Cc: kernel-hardening@lists.openwall.com, Sergey Senozhatsky , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Steven Rostedt , William Roberts , Chris Fries , Dave Weinstein Subject: Re: [RFC 1/6] lib: vsprintf: additional kernel pointer filtering options Message-ID: <20170518141203.GB23654@kroah.com> References: <20170506040641.GA32707@kroah.com> <20170506040656.GB32707@kroah.com> <20170516115811.GA7297@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170516115811.GA7297@pathway.suse.cz> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 16, 2017 at 01:58:11PM +0200, Petr Mladek wrote: > On Fri 2017-05-05 21:06:56, Greg KH wrote: > > From: Dave Weinstein > > > > Add the kptr_restrict setting of 3 which results in both > > %p and %pK values being replaced by zeros. > > > > Add an additional %pP value inspired by the Grsecurity > > option which explicitly whitelists pointers for output. > > > > This patch is based on work by William Roberts > > > > > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > > index e3bf4e0f10b5..f4e11dade1ab 100644 > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -395,6 +395,16 @@ struct printf_spec { > > #define FIELD_WIDTH_MAX ((1 << 23) - 1) > > #define PRECISION_MAX ((1 << 15) - 1) > > > > +int kptr_restrict __read_mostly; > > + > > +/* > > + * Always cleanse %p and %pK specifiers > > + */ > > +static inline int kptr_restrict_always_cleanse_pointers(void) > > The name of the function is very long and still confusing. > It uses the word "always" but there are many types of pointers > that are not cleared with this condition, for example %pP, %pa. > > Do we need this helper function at all? It is used > a weird way, see below. Thanks for the comments, I'll revise this for the next version, thanks so much for the review, much appreciated. thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 18 May 2017 16:12:03 +0200 From: Greg KH Message-ID: <20170518141203.GB23654@kroah.com> References: <20170506040641.GA32707@kroah.com> <20170506040656.GB32707@kroah.com> <20170516115811.GA7297@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170516115811.GA7297@pathway.suse.cz> Subject: [kernel-hardening] Re: [RFC 1/6] lib: vsprintf: additional kernel pointer filtering options To: Petr Mladek Cc: kernel-hardening@lists.openwall.com, Sergey Senozhatsky , linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Steven Rostedt , William Roberts , Chris Fries , Dave Weinstein List-ID: On Tue, May 16, 2017 at 01:58:11PM +0200, Petr Mladek wrote: > On Fri 2017-05-05 21:06:56, Greg KH wrote: > > From: Dave Weinstein > > > > Add the kptr_restrict setting of 3 which results in both > > %p and %pK values being replaced by zeros. > > > > Add an additional %pP value inspired by the Grsecurity > > option which explicitly whitelists pointers for output. > > > > This patch is based on work by William Roberts > > > > > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > > index e3bf4e0f10b5..f4e11dade1ab 100644 > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -395,6 +395,16 @@ struct printf_spec { > > #define FIELD_WIDTH_MAX ((1 << 23) - 1) > > #define PRECISION_MAX ((1 << 15) - 1) > > > > +int kptr_restrict __read_mostly; > > + > > +/* > > + * Always cleanse %p and %pK specifiers > > + */ > > +static inline int kptr_restrict_always_cleanse_pointers(void) > > The name of the function is very long and still confusing. > It uses the word "always" but there are many types of pointers > that are not cleared with this condition, for example %pP, %pa. > > Do we need this helper function at all? It is used > a weird way, see below. Thanks for the comments, I'll revise this for the next version, thanks so much for the review, much appreciated. thanks, greg k-h