public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jann Horn <jann@thejh.net>
To: "Roberts, William C" <william.c.roberts@intel.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [kernel-hardening] RE: [PATCH] printk: introduce kptr_restrict level 3
Date: Fri, 7 Oct 2016 13:52:39 +0200	[thread overview]
Message-ID: <20161007115239.GA14666@pc.thejh.net> (raw)
In-Reply-To: <20161006140553.GY14666@pc.thejh.net>

[-- Attachment #1: Type: text/plain, Size: 2586 bytes --]

On Thu, Oct 06, 2016 at 04:05:53PM +0200, Jann Horn wrote:
> On Thu, Oct 06, 2016 at 01:47:47PM +0000, Roberts, William C wrote:
> > > -----Original Message-----
> > > From: Christoph Hellwig [mailto:hch@infradead.org]
> > > Sent: Thursday, October 6, 2016 9:32 AM
> > > To: Roberts, William C <william.c.roberts@intel.com>
> > > Cc: kernel-hardening@lists.openwall.com; corbet@lwn.net; linux-
> > > doc@vger.kernel.org; linux-kernel@vger.kernel.org
> > > Subject: Re: [PATCH] printk: introduce kptr_restrict level 3
> > > 
> > > On Wed, Oct 05, 2016 at 02:04:46PM -0400, william.c.roberts@intel.com wrote:
> > > > From: William Roberts <william.c.roberts@intel.com>
> > > >
> > > > 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.
> > > 
> > > So what?  We a) don't care about out of tree modules and b) you could just triviall
> > > fix them up if you care.
> > 
> > Out of tree modules still affect core kernel security. I would also bet money, that somewhere
> > In-tree someone has put a %p when they wanted a %pK. So this method is just quite error
> > prone. We currently have a blacklist approach versus whitelist.
> 
> grep says you have a point:
> 
> $ grep -IR 'seq_printf.*%p[^FfSsBRrhbMmIiEUVKNadCDgG].*&'
> drivers/dma/qcom/hidma_dbg.c:	seq_printf(s, "dev_trca=%p\n", &dmadev->dev_trca);
> drivers/dma/qcom/hidma_dbg.c:	seq_printf(s, "dev_evca=%p\n", &dmadev->dev_evca);
> 
> $ grep -IR 'pr_info.*%p[^FfSsBRrhbMmIiEUVKNadCDgG].*&'
> drivers/misc/lkdtm_heap.c:	pr_info("Allocated memory %p-%p\n", base, &base[offset * 2]);
> 
> $ grep -IR 'pr_err.*%p[^FfSsBRrhbMmIiEUVKNadCDgG].*&'
> drivers/net/ethernet/qlogic/qlge/qlge_dbg.c:	pr_err("rx_ring->cqicb = %p\n", &rx_ring->cqicb);

Actually, I think I missed something here.

We don't really want to censor pointers in dmesg, right? dmesg can
contain pointers by design - and in particular, when an oops
happens, the register dump will reveal pointers. dmesg should just
be restricted using dmesg_restrict.

(What is annoying, though, is that e.g. Debian's default rsyslog
config sends all KERN_EMERG messages to all active PTYs by default,
meaning that on a system with such a config, making the kernel oops
can be used to leak some ASLR information.)

(And why does __die() in arch/x86/kernel/dumpstack.c use KERN_EMERG
for CONFIG_X86_32, but KERN_ALERT for !CONFIG_X86_32?)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2016-10-07 11:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 18:04 [PATCH] printk: introduce kptr_restrict level 3 william.c.roberts
2016-10-05 19:34 ` Kees Cook
2016-10-06 13:17   ` Roberts, William C
2016-10-05 20:52 ` Rasmus Villemoes
2016-10-06 13:23   ` Roberts, William C
2016-10-06 13:31 ` Christoph Hellwig
2016-10-06 13:47   ` Roberts, William C
2016-10-06 13:56     ` Christoph Hellwig
2016-10-06 14:59       ` Roberts, William C
2016-10-06 21:00       ` Kees Cook
2016-10-06 21:19         ` Joe Perches
2016-10-06 21:25           ` Kees Cook
2016-10-07 14:21         ` Roberts, William C
2016-10-06 14:05     ` [kernel-hardening] " Jann Horn
2016-10-06 14:46       ` Jann Horn
2016-10-07 11:52       ` Jann Horn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161007115239.GA14666@pc.thejh.net \
    --to=jann@thejh.net \
    --cc=corbet@lwn.net \
    --cc=hch@infradead.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=william.c.roberts@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox