From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941921AbcJFNRX (ORCPT ); Thu, 6 Oct 2016 09:17:23 -0400 Received: from mga11.intel.com ([192.55.52.93]:13823 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755307AbcJFNRO (ORCPT ); Thu, 6 Oct 2016 09:17:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,454,1473145200"; d="scan'208";a="16906565" From: "Roberts, William C" To: Kees Cook CC: "kernel-hardening@lists.openwall.com" , Jonathan Corbet , "linux-doc@vger.kernel.org" , LKML , Nick Desaulniers , Dave Weinstein Subject: RE: [PATCH] printk: introduce kptr_restrict level 3 Thread-Topic: [PATCH] printk: introduce kptr_restrict level 3 Thread-Index: AQHSHzL4SKECDv3ohUe9odM8/3/liaCatdKAgACzMdA= Date: Thu, 6 Oct 2016 13:17:11 +0000 Message-ID: <476DC76E7D1DF2438D32BFADF679FC561CD1458F@ORSMSX103.amr.corp.intel.com> References: <1475690686-16138-1-git-send-email-william.c.roberts@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2E1YTg3MDgtYzkzMy00Mjg1LThiZDUtZTM0Njk5MmUwZWM4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkdDNXJEY0lIdHY4NmxQZm5ndmo5ajR1RTUxcWNjbnljUXVrTTNEYlEzQVE9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.22.254.139] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u96DHRmh019734 > -----Original Message----- > From: keescook@google.com [mailto:keescook@google.com] On Behalf Of Kees > Cook > Sent: Wednesday, October 5, 2016 3:34 PM > To: Roberts, William C > Cc: kernel-hardening@lists.openwall.com; Jonathan Corbet ; > linux-doc@vger.kernel.org; LKML ; Nick > Desaulniers ; Dave Weinstein > Subject: Re: [PATCH] printk: introduce kptr_restrict level 3 > > On Wed, Oct 5, 2016 at 11:04 AM, wrote: > > From: William Roberts > > > > Some out-of-tree modules do not use %pK and just use %p, as it's the > > common C paradigm for printing pointers. Because of this, > > kptr_restrict has no affect on the output and thus, no way to contain > > the kernel address leak. > > Solving this is certainly a good idea -- I'm all for finding a solid solution. > > > Introduce kptr_restrict level 3 that causes the kernel to treat %p as > > if it was %pK and thus always prints zeros. > > I'm worried that this could break kernel internals where %p is being used and not > exposed to userspace. Maybe those situations don't exist... Not saying they don't I didn't find any. > > Regardless, I would rather do what Grsecurity has done in this area, and whitelist > known-safe values instead. For example, they have %pP for approved pointers, > and %pX for approved > dereference_function_descriptor() output. Everything else is censored if it is a > value in kernel memory and destined for a user-space memory > buffer: > > if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'X' && *fmt != > 'K' && is_usercopy_object(buf)) { > printk(KERN_ALERT "grsec: kernel infoleak detected! > Please report this log to spender@grsecurity.net.\n"); > dump_stack(); > ptr = NULL; > } > > The "is_usercopy_object()" test is something we can add, which is testing for a > new SLAB flag that is used to mark slab caches as either used by user-space or > not, which is done also through whitelisting. > (For more details on this, see: > http://www.openwall.com/lists/kernel-hardening/2016/06/08/10) > > Would you have time/interest to add the slab flags and is_usercopy_object()? > The hardened usercopy part of the slab whitelisting can be separate, since it likely > needs a different usercopy interface to sanely integrate with upstream. I could likely take this on. I would need to read up on the links and have a better concept of what it is. > > -Kees > > -- > Kees Cook > Nexus Security