From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932476AbdJQFUR (ORCPT ); Tue, 17 Oct 2017 01:20:17 -0400 Received: from smtprelay0051.hostedemail.com ([216.40.44.51]:45463 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932418AbdJQFUQ (ORCPT ); Tue, 17 Oct 2017 01:20:16 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:2892:2894:2895:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3872:4321:5007:6742:7903:8957:10004:10400:10848:11232:11658:11783:11914:12043:12296:12438:12740:12895:13069:13161:13229:13311:13357:13439:13894:14659:14721:21080:21451:21627:30012:30054:30075:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: trade39_58ded4aa2b111 X-Filterd-Recvd-Size: 2617 Message-ID: <1508217608.6530.20.camel@perches.com> Subject: Re: [PATCH v2] printk: hash addresses printed with %p From: Joe Perches To: "Tobin C. Harding" , kernel-hardening@lists.openwall.com Cc: Linus Torvalds , Kees Cook , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , linux-kernel@vger.kernel.org Date: Mon, 16 Oct 2017 22:20:08 -0700 In-Reply-To: <1508215972-7769-1-git-send-email-me@tobin.cc> References: <1508215972-7769-1-git-send-email-me@tobin.cc> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2017-10-17 at 15:52 +1100, 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. > > For what it's worth, usage of unadorned %p can be broken down as follows > > git grep '%p[^KFfSsBRrbMmIiEUVKNhdDgCGO]' | wc -l Not really. There are many asm uses included there I think a better grep is: $ git grep -E '%p[^A-Za-z0-9]' | cut -f1 -d"/" | sort | uniq -c    1084 arch      20 block      10 crypto      32 Documentation    8121 drivers    1221 fs     143 include     101 kernel      69 lib     100 mm    1510 net      40 samples       7 scripts      11 security     166 sound     152 tools       2 virt > arch: 2512 arch is especially overestimated.