[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161006144656.GZ14666@pc.thejh.net>
Date: Thu, 6 Oct 2016 16:46:56 +0200
From: Jann Horn <jann@...jh.net>
To: "Roberts, William C" <william.c.roberts@...el.com>
Cc: Christoph Hellwig <hch@...radead.org>,
"kernel-hardening@...ts.openwall.com"
<kernel-hardening@...ts.openwall.com>,
"corbet@....net" <corbet@....net>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [kernel-hardening] RE: [PATCH] printk: introduce kptr_restrict
level 3
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@...radead.org]
> > > Sent: Thursday, October 6, 2016 9:32 AM
> > > To: Roberts, William C <william.c.roberts@...el.com>
> > > Cc: kernel-hardening@...ts.openwall.com; corbet@....net; linux-
> > > doc@...r.kernel.org; linux-kernel@...r.kernel.org
> > > Subject: Re: [PATCH] printk: introduce kptr_restrict level 3
> > >
> > > On Wed, Oct 05, 2016 at 02:04:46PM -0400, william.c.roberts@...el.com wrote:
> > > > From: William Roberts <william.c.roberts@...el.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);
>
> And these are just trivially greppable, low-hanging-fruit ones.
> With somewhat broader greps, there seem to be lots more, but they'd
> require manual review.
(Although, of course, most matches for seq_printf are in debugfs
files or stuff that's only enabled with some DEBUG config option
or so. But there are also e.g. pr_warn() users of %p that are not
in debug code.)
Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)
Powered by blists - more mailing lists