From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 27 Oct 2017 22:33:01 +0900 From: Sergey Senozhatsky Message-ID: <20171027133301.GA612@tigerII.localdomain> 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: <1508986436-31966-1-git-send-email-me@tobin.cc> Subject: [kernel-hardening] Re: [PATCH V8 0/2] printk: hash addresses printed with %p To: "Tobin C. Harding" Cc: kernel-hardening@lists.openwall.com, "Jason A. Donenfeld" , Theodore Ts'o , Linus Torvalds , Kees Cook , 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 , linux-kernel@vger.kernel.org List-ID: On (10/26/17 13:53), Tobin C. Harding wrote: > Currently there are many places in the kernel where addresses are being > printed using an unadorned %p. Kernel pointers should be printed using > %pK allowing some control via the kptr_restrict sysctl. Exposing > addresses gives attackers sensitive information about the kernel layout > in memory. > > We can reduce the attack surface by hashing all addresses printed with > %p. This will of course break some users, forcing code printing needed > addresses to be updated. > > With this version we include hashing of malformed specifiers also. > Malformed specifiers include incomplete (e.g %pi) and also non-existent > specifiers. checkpatch should warn for non-existent specifiers but > AFAICT won't warn for incomplete specifiers. > > 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 > NULL pointer: > printed with %pK: 0000000000000000 > printed with %p: (null) # NOTE: no padding > malformed specifier (eg %i): (null) a quick question: do we care about cases when kernel pointers are printed with %x/%X and not with %p? -ss From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752471AbdJ0NdG (ORCPT ); Fri, 27 Oct 2017 09:33:06 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:46195 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752118AbdJ0NdE (ORCPT ); Fri, 27 Oct 2017 09:33:04 -0400 X-Google-Smtp-Source: ABhQp+RraDBybbnita/ZI981ss8VlatZTL9iQT+jhiM5lr7ge3EQt5ThHJrU+sBixxq4EcyQYqH/TA== Date: Fri, 27 Oct 2017 22:33:01 +0900 From: Sergey Senozhatsky To: "Tobin C. Harding" Cc: kernel-hardening@lists.openwall.com, "Jason A. Donenfeld" , "Theodore Ts'o" , Linus Torvalds , Kees Cook , 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 , linux-kernel@vger.kernel.org Subject: Re: [PATCH V8 0/2] printk: hash addresses printed with %p Message-ID: <20171027133301.GA612@tigerII.localdomain> 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: <1508986436-31966-1-git-send-email-me@tobin.cc> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (10/26/17 13:53), Tobin C. Harding wrote: > Currently there are many places in the kernel where addresses are being > printed using an unadorned %p. Kernel pointers should be printed using > %pK allowing some control via the kptr_restrict sysctl. Exposing > addresses gives attackers sensitive information about the kernel layout > in memory. > > We can reduce the attack surface by hashing all addresses printed with > %p. This will of course break some users, forcing code printing needed > addresses to be updated. > > With this version we include hashing of malformed specifiers also. > Malformed specifiers include incomplete (e.g %pi) and also non-existent > specifiers. checkpatch should warn for non-existent specifiers but > AFAICT won't warn for incomplete specifiers. > > 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 > NULL pointer: > printed with %pK: 0000000000000000 > printed with %p: (null) # NOTE: no padding > malformed specifier (eg %i): (null) a quick question: do we care about cases when kernel pointers are printed with %x/%X and not with %p? -ss