Re: [PATCH v2] sanitize task->comm to avoid leaking escape codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
> > 
> > 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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux