From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757114Ab3JRTJJ (ORCPT ); Fri, 18 Oct 2013 15:09:09 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.226]:13469 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753519Ab3JRTJH (ORCPT ); Fri, 18 Oct 2013 15:09:07 -0400 Date: Fri, 18 Oct 2013 15:09:03 -0400 From: Steven Rostedt To: Andrey Konovalov Cc: Dave Jones , linux-kernel@vger.kernel.org, =?UTF-8?B?RnLDqWTDqXJpYw==?= Weisbecker , mingo@redhat.com, Dmitry Vyukov , Kostya Serebryany Subject: Re: Potential out-of-bounds in ftrace_regex_release Message-ID: <20131018150903.22f75457@gandalf.local.home> In-Reply-To: References: <20131002185723.GA32614@redhat.com> <1380745082.12351.6.camel@pippen.local.home> <20131002223437.GA15728@redhat.com> <20131009222323.04fd1a0d@gandalf.local.home> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.20; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.142:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Oct 2013 12:29:13 +0400 Andrey Konovalov wrote: > Testing now with your patch. > I've seen this report only twice, so it will be difficult to say if > it's not happening any more or just not triggered. Can I assume that this is fixed? I'll put it in for 3.12 and mark it for stable too. -- Steve > > On Thu, Oct 10, 2013 at 6:23 AM, Steven Rostedt wrote: > > On Wed, 9 Oct 2013 14:05:26 +0400 > > Andrey Konovalov wrote: > >time cat trace > /tmp/trace > >> So I still think that the bug is in 'trage_get_user()': > >> Checking that 'parser->idx < parser->size - 1' is not performed in 'if > >> (isspace(ch))' section, so 'parser->idx' becomes equal to > >> 'parser->size' after 'parser->buffer[parser->idx++] = ch;'. > >> (However in 'while (cnt && !isspace(ch))' loop checking is performed.) > > > > Yep, you are correct. I put in some printk's and did same writing to > > the set_events file and was able to prove that I could get that "0" > > written into the +1 overflow boundary. > > > > Can you try this patch to see if it fixes it for you. > > > > Thanks, > > > > -- Steve > > > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > > index d5f7c4d..063a92b 100644 > > --- a/kernel/trace/trace.c > > +++ b/kernel/trace/trace.c > > @@ -843,9 +843,12 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, > > if (isspace(ch)) { > > parser->buffer[parser->idx] = 0; > > parser->cont = false; > > - } else { > > + } else if (parser->idx < parser->size - 1) { > > parser->cont = true; > > parser->buffer[parser->idx++] = ch; > > + } else { > > + ret = -EINVAL; > > + goto out; > > } > > > > *ppos += read; > >