From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 31 Oct 2017 09:33:46 +1100 From: "Tobin C. Harding" Message-ID: <20171030223346.GX12341@eros> References: <1508986436-31966-1-git-send-email-me@tobin.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [kernel-hardening] Re: [PATCH V8 0/2] printk: hash addresses printed with %p To: Kees Cook Cc: kernel-hardening@lists.openwall.com, "Jason A. Donenfeld" , Theodore Ts'o , Linus Torvalds , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Joe Perches , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , LKML List-ID: On Mon, Oct 30, 2017 at 03:03:21PM -0700, Kees Cook wrote: > On Wed, Oct 25, 2017 at 7:53 PM, Tobin C. Harding wrote: > > Here is the behaviour that this set implements. > > > > For kpt_restrict==0 > > > > Randomness not ready: > > printed with %p: (pointer) # NOTE: with padding > > Valid pointer: > > printed with %pK: deadbeefdeadbeef > > printed with %p: 0xdeadbeef > > malformed specifier (eg %i): 0xdeadbeef > > I really think we can't include SPECIAL unless _every_ callsite of %p > is actually doing "0x%p", and then we're replacing all of those. We're > not doing that, though... > > $ git grep '%p\b' | wc -l > 12766 > $ git grep '0x%p\b' | wc -l > 1837 > > If we need some kind of special marking that this is a hashed > variable, that should be something other than "0x". If we're using the > existing "(null)" and new "(pointer)" text, maybe "(hash:xxxxxx)" > should be used instead? Then the (rare) callers with 0x become > "0x(hash:xxxx)" and naked callers produce "(hash:xxxx)". > > I think the first step for this is to just leave SPECIAL out. Thanks Kees. V9 leaves SPECIAL out. Also V9 prints the whole 64 bit address with the first 32 bits masked to zero. The intent being to _not_ change the output format from what it currently is. So it will look like this; 00000000c09e81d0 What do you think? Amusingly I think this whole conversation is going to come up again when we do %pa, in inverse, since %pa currently does us SPECIAL. thanks, Tobin. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbdJ3Wdx (ORCPT ); Mon, 30 Oct 2017 18:33:53 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:37205 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752975AbdJ3Wdw (ORCPT ); Mon, 30 Oct 2017 18:33:52 -0400 X-ME-Sender: Date: Tue, 31 Oct 2017 09:33:46 +1100 From: "Tobin C. Harding" To: Kees Cook Cc: kernel-hardening@lists.openwall.com, "Jason A. Donenfeld" , "Theodore Ts'o" , Linus Torvalds , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Joe Perches , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , LKML Subject: Re: [PATCH V8 0/2] printk: hash addresses printed with %p Message-ID: <20171030223346.GX12341@eros> References: <1508986436-31966-1-git-send-email-me@tobin.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: Mutt 1.5.24 (2015-08-30) User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 30, 2017 at 03:03:21PM -0700, Kees Cook wrote: > On Wed, Oct 25, 2017 at 7:53 PM, Tobin C. Harding wrote: > > Here is the behaviour that this set implements. > > > > For kpt_restrict==0 > > > > Randomness not ready: > > printed with %p: (pointer) # NOTE: with padding > > Valid pointer: > > printed with %pK: deadbeefdeadbeef > > printed with %p: 0xdeadbeef > > malformed specifier (eg %i): 0xdeadbeef > > I really think we can't include SPECIAL unless _every_ callsite of %p > is actually doing "0x%p", and then we're replacing all of those. We're > not doing that, though... > > $ git grep '%p\b' | wc -l > 12766 > $ git grep '0x%p\b' | wc -l > 1837 > > If we need some kind of special marking that this is a hashed > variable, that should be something other than "0x". If we're using the > existing "(null)" and new "(pointer)" text, maybe "(hash:xxxxxx)" > should be used instead? Then the (rare) callers with 0x become > "0x(hash:xxxx)" and naked callers produce "(hash:xxxx)". > > I think the first step for this is to just leave SPECIAL out. Thanks Kees. V9 leaves SPECIAL out. Also V9 prints the whole 64 bit address with the first 32 bits masked to zero. The intent being to _not_ change the output format from what it currently is. So it will look like this; 00000000c09e81d0 What do you think? Amusingly I think this whole conversation is going to come up again when we do %pa, in inverse, since %pa currently does us SPECIAL. thanks, Tobin.