Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932940AbbDQTTL (ORCPT ); Fri, 17 Apr 2015 15:19:11 -0400 Received: from smtprelay0095.hostedemail.com ([216.40.44.95]:57641 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932769AbbDQTTI (ORCPT ); Fri, 17 Apr 2015 15:19:08 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:69:355:379:541:800:960:967:973:988:989:1260:1263:1277:1311:1313:1314:1345:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2525:2553:2560:2563:2682:2685:2859:2898:2901:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3770:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6119:6261:7266:7903:8599:8660:9025:9121:10004:10400:10848:11026:11233:11256:11473:11658:11914:12043:12262:12266:12438:12517:12519:12555:12679:12740:12783:13148:13230:13255:13846:13870:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: toe93_324f07c86f657 X-Filterd-Recvd-Size: 3205 Date: Fri, 17 Apr 2015 15:19:04 -0400 From: Steven Rostedt To: LKML Cc: Ingo Molnar , Andrew Morton , Sasha Levin , Andrey Ryabinin Subject: [for-next][PATCH] tracing: Fix possible out of bounds memory access when parsing enums Message-ID: <20150417151904.7cbb8f85@gandalf.local.home> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next Head SHA1: 3193899d4dd54056f8c2e0b1e40dd6e2f0009f28 Steven Rostedt (Red Hat) (1): tracing: Fix possible out of bounds memory access when parsing enums ---- kernel/trace/trace_events.c | 6 ++++++ 1 file changed, 6 insertions(+) --------------------------- commit 3193899d4dd54056f8c2e0b1e40dd6e2f0009f28 Author: Steven Rostedt (Red Hat) Date: Fri Apr 17 10:27:57 2015 -0400 tracing: Fix possible out of bounds memory access when parsing enums The code that replaces the enum names with the enum values in the tracepoints' format files could possible miss the end of string nul character. This was caused by processing things like backslashes, quotes and other tokens. After processing the tokens, a check for the nul character needed to be done before continuing the loop, because the loop incremented the pointer before doing the check, which could bypass the nul character. Link: http://lkml.kernel.org/r/552E661D.5060502@oracle.com Reported-by: Sasha Levin # via KASan Tested-by: Andrey Ryabinin Fixes: 0c564a538aa9 "tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values" Signed-off-by: Steven Rostedt diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 36a957c996c7..b49c107f82ac 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1760,6 +1760,8 @@ static void update_event_printk(struct ftrace_event_call *call, ptr++; /* Check for alpha chars like ULL */ } while (isalnum(*ptr)); + if (!*ptr) + break; /* * A number must have some kind of delimiter after * it, and we can ignore that too. @@ -1786,12 +1788,16 @@ static void update_event_printk(struct ftrace_event_call *call, do { ptr++; } while (isalnum(*ptr) || *ptr == '_'); + if (!*ptr) + break; /* * If what comes after this variable is a '.' or * '->' then we can continue to ignore that string. */ if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) { ptr += *ptr == '.' ? 1 : 2; + if (!*ptr) + break; goto skip_more; } /*