linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jessica Yu <jeyu@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	Ingo Molnar <mingo@kernel.org>, Petr Mladek <pmladek@suse.com>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] kprobes: propagate error from arm_kprobe_ftrace()
Date: Fri, 3 Nov 2017 13:33:12 -0400	[thread overview]
Message-ID: <20171103133312.1a0646e2@vmware.local.home> (raw)
In-Reply-To: <20171103145337.wk5mib253q74pfuz@treble>

On Fri, 3 Nov 2017 09:53:37 -0500
Josh Poimboeuf <jpoimboe@redhat.com> 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

  reply	other threads:[~2017-11-03 17:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 16:33 [PATCH v2 0/2] kprobes: improve error handling when arming/disarming kprobes Jessica Yu
2017-11-02 16:33 ` [PATCH v2 1/2] kprobes: propagate error from arm_kprobe_ftrace() Jessica Yu
2017-11-03 14:03   ` Steven Rostedt
2017-11-03 14:53     ` Josh Poimboeuf
2017-11-03 17:33       ` Steven Rostedt [this message]
2017-11-03 20:35         ` Masami Hiramatsu
2017-11-07 17:14     ` Jessica Yu
2017-11-09  0:35       ` Masami Hiramatsu
2017-11-21 14:47         ` Jessica Yu
2017-11-03 21:49   ` [PATCH v2 1/2] " Masami Hiramatsu
2017-11-02 16:33 ` [PATCH v2 2/2] kprobes: propagate error from disarm_kprobe_ftrace() Jessica Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171103133312.1a0646e2@vmware.local.home \
    --to=rostedt@goodmis.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=pmladek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).