All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-security-module@vger.kernel.org, jmorris@namei.org,
	eric.dumazet@gmail.com, tgraf@infradead.org,
	eugeneteo@kernel.org, kees.cook@canonical.com,
	davem@davemloft.net, a.p.zijlstra@chello.nl,
	akpm@linux-foundation.org, eparis@parisplace.org
Subject: Re: [PATCH v5] kptr_restrict for hiding kernel pointers
Date: Wed, 22 Dec 2010 22:26:09 +0100	[thread overview]
Message-ID: <20101222212609.GD3139@elte.hu> (raw)
In-Reply-To: <1293039332.9820.262.camel@dan>


* Dan Rosenberg <drosenberg@vsecurity.com> wrote:

> On Wed, 2010-12-22 at 18:13 +0100, Ingo Molnar wrote:
> > * Dan Rosenberg <drosenberg@vsecurity.com> wrote:
> > 
> > > +	case 'K':
> > > +		/*
> > > +		 * %pK cannot be used in IRQ context because its test
> > > +		 * for CAP_SYSLOG would be meaningless.
> > > +		 */
> > > +		if (in_irq() || in_serving_softirq() || in_nmi())
> > > +			WARN_ONCE(1, "%%pK used in interrupt context.\n");
> > 
> > Hm, that bit looks possibly broken - some useful warning in irq context could print 
> > a pointer into the syslog and this would generate a second warning? That probably 
> > would crash as it recurses back into the printk code?
> > 
> 
> I don't see a reason to ever use %pK to print to the syslog, since
> reading it is now optionally protected with dmesg_restrict, and
> stripping pointers from the syslog will cripple any post-mortem
> debugging for everyone.  I understand the desire to prevent things from
> breaking even if it's used incorrectly, but I'm not really convinced
> that this would break anything even in this scenario.  The WARN_ONCE
> will prevent any unbounded recursion.  I'm just not clear on how this
> could cause a crash.

It's a simple QOI issue. We simply do not add kernel facilities that can produce a 
stack overflow, memory corruption and triple fault if a rare debug statement 
triggers in an IRQ context by accident:

	printk(KERN_WARN "driver bar: bug foo in function %pK\n");

> > Instead a warning could be inserted into the generated output instead, for 
> > example 'pK-error' (carefully staying within pointer length limits).
> 
> If it's used in IRQ context and its output needs to be read by a
> userspace utility using %p to parse, this will break it.

Didnt you just say that it should not be used from IRQ context? There wont be any 
user-space tool to read it - it's a simple robustness change: the warning as you 
implemented it can crash the system. I suggested an implementation that would emit 
the warning in a more robust way.

Thanks,

	Ingo

      reply	other threads:[~2010-12-22 21:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-22 17:00 [PATCH v5] kptr_restrict for hiding kernel pointers Dan Rosenberg
2010-12-22 17:13 ` Ingo Molnar
2010-12-22 17:17   ` Dan Rosenberg
2010-12-22 17:19     ` Dan Rosenberg
2010-12-22 21:43     ` Valdis.Kletnieks
2010-12-22 17:35   ` Dan Rosenberg
2010-12-22 21:26     ` Ingo Molnar [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=20101222212609.GD3139@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=drosenberg@vsecurity.com \
    --cc=eparis@parisplace.org \
    --cc=eric.dumazet@gmail.com \
    --cc=eugeneteo@kernel.org \
    --cc=jmorris@namei.org \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.