public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees.cook@canonical.com>
To: Stefani Seibold <stefani@seibold.net>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>, Veaceslav Falico <vfalico@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Oleg Nesterov <oleg@redhat.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Roland McGrath <roland@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Eric Paris <eparis@redhat.com>, James Morris <jmorris@namei.org>,
	"Andrew G. Morgan" <morgan@kernel.org>,
	Dhaval Giani <dhaval.giani@gmail.com>,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	Steve Grubb <sgrubb@redhat.com>, Christoph Hellwig <hch@lst.de>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] sanitize task->comm to avoid leaking escape codes
Date: Mon, 28 Jun 2010 11:04:28 -0700	[thread overview]
Message-ID: <20100628180428.GQ4175@outflux.net> (raw)
In-Reply-To: <1277747318.4840.9.camel@wall-e.seibold.net>

On Mon, Jun 28, 2010 at 07:48:38PM +0200, Stefani Seibold wrote:
> Am Freitag, den 25.06.2010, 08:56 +0900 schrieb KOSAKI Motohiro:
> > > Through get_task_comm() and many direct uses of task->comm in the kernel,
> > > it is possible for escape codes and other non-printables to leak into
> > > dmesg, syslog, etc.  In the worst case, these strings could be used to
> > > attack administrators using vulnerable terminal emulators, and at least
> > > cause confusion through the injection of \r characters.
> > > 
> > > This patch sanitizes task->comm to only contain printable characters
> > > when it is set.  Additionally, it redefines get_task_comm so that it is
> > > more obvious when misused by callers (presently nothing was incorrectly
> > > calling get_task_comm's unsafe use of strncpy).
> > > 
> > > Signed-off-by: Kees Cook <kees.cook@canonical.com>
> > 
> > I've reviewed this patch briefly, Here is my personal concern...
> > 
> > On Linux, non-printable leaking is fundamental, only fixing task->comm
> > doesn't solve syslog exploit issue. Probably all /proc/kmsg user should
> > have escaping non-pritables code.
> > 
> > However, task->comm is one of most easy injection data of kernel, because
> > we have prctl(PR_SET_NAME), attacker don't need root privilege. So,
> > conservative assumption seems guard from crappy fault. Plus, this patch
> > is very small and our small TASK_COMM_LEN lead that we don't need
> > big performance concern.
> > 
> > So, I don't find demerit in this proposal. but I'm not security specialist,
> > it's only personal thinking.
> > 
> Agree. I think a escaped printk should be a more generic solution.

I think sanitizing inputs is more effective than sanitizing outputs.
If ->comm is safe internally, then we don't have to filter it going out
on printk, audit, /proc output, etc.  There is a limited number of places
where a process has control over an arbitrary string in kernel structures,
so the places where they are set should be fixed instead of fixing every
possible usage of it on output.

I wouldn't mind sanitizing printk also, but it's tangential to sanitizing
task->comm when it is set.

-Kees

-- 
Kees Cook
Ubuntu Security Team

  reply	other threads:[~2010-06-28 18:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24 19:05 [PATCH v2] sanitize task->comm to avoid leaking escape codes Kees Cook
2010-06-24 23:56 ` KOSAKI Motohiro
2010-06-28 17:48   ` Stefani Seibold
2010-06-28 18:04     ` Kees Cook [this message]
2010-06-29  3:05     ` KOSAKI Motohiro
2010-06-29 12:58       ` Steve Grubb
2010-06-30  0:16         ` KOSAKI Motohiro
2010-06-30  0:22           ` Steve Grubb
2010-06-30  0:28             ` KOSAKI Motohiro
2010-06-29  9:36 ` Alan Cox
2010-06-29 14:51   ` Kees Cook
2010-06-30  9:13     ` Alan Cox
2010-06-30  0:31   ` KOSAKI Motohiro

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=20100628180428.GQ4175@outflux.net \
    --to=kees.cook@canonical.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=dhaval.giani@gmail.com \
    --cc=eparis@redhat.com \
    --cc=gregkh@suse.de \
    --cc=hch@lst.de \
    --cc=jmorris@namei.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=morgan@kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=oleg@redhat.com \
    --cc=roland@redhat.com \
    --cc=serue@us.ibm.com \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=sgrubb@redhat.com \
    --cc=stefani@seibold.net \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vfalico@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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