From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Subject: Re: [PATCH v2] sanitize task->comm to avoid leaking escape codes Date: Tue, 29 Jun 2010 07:51:37 -0700 Message-ID: <20100629145137.GD4175@outflux.net> References: <20100624190527.GD5917@outflux.net> <20100629103650.3b80e09f@lxorguk.ukuu.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , Tejun Heo , Veaceslav Falico , Alexander Viro , Oleg Nesterov , KOSAKI Motohiro , Neil Horman , Roland McGrath , Ingo Molnar , Peter Zijlstra , Hidetoshi Seto , Stefani Seibold , Thomas Gleixner , Eric Paris , James Morris , "Andrew G. Morgan" , Dhaval Giani , "Serge E. Hallyn" , Steve Grubb , Christoph Hellwig , linux-fsdevel@vger.kernel.org To: Alan Cox Return-path: Content-Disposition: inline In-Reply-To: <20100629103650.3b80e09f@lxorguk.ukuu.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Tue, Jun 29, 2010 at 10:36:50AM +0100, Alan Cox wrote: > > 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. > > If an administrator has a vulnerable terminal emulator they have other > problems. Totally agreed. > Please do any filtering you must in the yama security module where it > only affects that. One way to approach it without losing data within the > module might be to use HTML style encoding within Yama so your own tools > can undo the 'sanitizing' rather than losing information ? I'm not interested in sanitizing this in Yama. The use of task->comm via printk was seen as a flaw. I didn't agree (see above about terminal), and suggested that if it was a flaw, it was a flaw with printk or task->comm itself. Since "fixing" both of those have been vetoed, I have no more interest in the filtering. What I do have interest in is fixing get_task_comm's use of buffers, which is theoretically problematic in some future where someone accidentally calls it with a buffer smaller than sizeof(task->comm). I'll send a patch that only fixes that and leaves out the filtering. -Kees -- Kees Cook Ubuntu Security Team