From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756352AbdKCRdT (ORCPT ); Fri, 3 Nov 2017 13:33:19 -0400 Received: from smtprelay0162.hostedemail.com ([216.40.44.162]:39821 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756307AbdKCRdR (ORCPT ); Fri, 3 Nov 2017 13:33:17 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:968: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:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:5007:6261:6742:7875:10004:10400:10848:10967:11026:11232:11658:11914:12043:12438:12663:12740:12760:12895:13069:13311:13357:13439:13972:14096:14097:14181:14659:14721:21080:21627:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: truck43_3957346ccad08 X-Filterd-Recvd-Size: 3236 Date: Fri, 3 Nov 2017 13:33:12 -0400 From: Steven Rostedt To: Josh Poimboeuf Cc: Jessica Yu , Masami Hiramatsu , Ananth N Mavinakayanahalli , Anil S Keshavamurthy , "David S . Miller" , Ingo Molnar , Petr Mladek , Joe Lawrence , Jiri Kosina , Miroslav Benes , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] kprobes: propagate error from arm_kprobe_ftrace() Message-ID: <20171103133312.1a0646e2@vmware.local.home> In-Reply-To: <20171103145337.wk5mib253q74pfuz@treble> References: <20171102163334.3947-1-jeyu@kernel.org> <20171102163334.3947-2-jeyu@kernel.org> <20171103100317.01db273b@vmware.local.home> <20171103145337.wk5mib253q74pfuz@treble> X-Mailer: Claws Mail 3.15.1-dirty (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, 3 Nov 2017 09:53:37 -0500 Josh Poimboeuf wrote: > > > -static void arm_kprobe_ftrace(struct kprobe *p) > > > +static int arm_kprobe_ftrace(struct kprobe *p) > > > { > > > - int ret; > > > + int ret = 0; > > > > > > ret = ftrace_set_filter_ip(&kprobe_ftrace_ops, > > > (unsigned long)p->addr, 0, 0); > > > - WARN(ret < 0, "Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret); > > > - kprobe_ftrace_enabled++; > > > - if (kprobe_ftrace_enabled == 1) { > > > + if (WARN(ret < 0, "Failed to arm kprobe-ftrace at %p (%d)\n", p->addr, ret)) > > > + return ret; > > > + > > > + if (kprobe_ftrace_enabled == 0) { > > > ret = register_ftrace_function(&kprobe_ftrace_ops); > > > - WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret); > > > + if (WARN(ret < 0, "Failed to init kprobe-ftrace (%d)\n", ret)) > > > + goto err_ftrace; > > > } > > > + > > > + kprobe_ftrace_enabled++; > > > + return ret; > > > + > > > +err_ftrace: > > > + ftrace_set_filter_ip(&kprobe_ftrace_ops, (unsigned long)p->addr, 1, 0); > > > > Hmm, this could have a very nasty side effect. If you remove a function > > from the ops, and it was the last function, an empty ops means to trace > > *all* functions. > > But this error path only runs when register_ftrace_function() fails, in > which case the ops aren't live anyway, right? I was thinking that if there was more than one function that is going to be registered, that only this one would be black listed. But yeah, if there was only one function in the hash, then it probably wouldn't matter if it was cleared, because it failed. But I'm paranoid about things like this, and prefer to be more robust than to depend on the design to enforce correctness than to have each individual function being contained and do what is expected of it. -- Steve