From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751048AbdAMRPd (ORCPT ); Fri, 13 Jan 2017 12:15:33 -0500 Received: from smtprelay0182.hostedemail.com ([216.40.44.182]:33973 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750874AbdAMRPc (ORCPT ); Fri, 13 Jan 2017 12:15:32 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3874:4321:4362:5007:6261:7875:7903:8660:9040:10004:10400:10848:10967:11026:11232:11658:11914:12043:12438:12555:12740:12760:12895:12986:13069:13148:13230:13311:13357:13439:14093:14096:14097:14181:14659:14721:21080:21324:21451:30051:30054:30056:30064:30090:30091,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,LFtime:2,LUA_SUMMARY:none X-HE-Tag: birth32_5feb587874418 X-Filterd-Recvd-Size: 2582 Date: Fri, 13 Jan 2017 12:14:17 -0500 From: Steven Rostedt To: Kenny Yu Cc: , , , Subject: Re: [PATCH] uprobe: Find last occurrence of ':' when parsing uprobe PATH:OFFSET Message-ID: <20170113121417.26dcc3de@gandalf.local.home> In-Reply-To: <20170113165834.4081016-1-kennyyu@fb.com> References: <20170113165834.4081016-1-kennyyu@fb.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; 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 On Fri, 13 Jan 2017 08:58:34 -0800 Kenny Yu wrote: > Previously, `create_trace_uprobe` found the *first* occurence > of the ':' character when parsing `PATH:OFFSET` for a uprobe. > However, if the path contains a ':' character, then the function > would parse the path incorrectly. Even worse, if the path does not > exist, the subsequent call to `kern_path()` would set `ret` to > `ENOENT`, leading to very cryptic errno values in user space. > > The fix is to find the *last* occurence of ':'. > > How to repro:: The write fails with "No such file or directory", suggesting > incorrectly that the `uprobe_events` file does not exist. > > $ mkdir testing && cd testing > $ cp /bin/bash . > $ cp /bin/bash ./bash:with:colon > $ echo "p:uprobes/p__root_testing_bash_0x6 /root/testing/bash:0x6" > /sys/kernel/debug/tracing/uprobe_events # this works > $ echo "p:uprobes/p__root_testing_bash_with_colon_0x6 /root/testing/bash:with:colon:0x6" >> /sys/kernel/debug/tracing/uprobe_events # this doesn't > -bash: echo: write error: No such file or directory > > With the patch: > > $ echo "p:uprobes/p__root_testing_bash_0x6 /root/testing/bash:0x6" > /sys/kernel/debug/tracing/uprobe_events # this still works > $ echo "p:uprobes/p__root_testing_bash_with_colon_0x6 /root/testing/bash:with:colon:0x6" >> /sys/kernel/debug/tracing/uprobe_events # this works now too! > $ cat /sys/kernel/debug/tracing/uprobe_events > p:uprobes/p__root_testing_bash_0x6 /root/testing/bash:0x0000000000000006 > p:uprobes/p__root_testing_bash_with_colon_0x6 /root/testing/bash:with:colon:0x0000000000000006 > Thanks! I'll add this to my queue. -- Steve