All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Tom Zanussi <tom.zanussi@linux.intel.com>,
	"zhangwei(Jovi)" <jovi.zhangwei@huawei.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] tracing/uprobes: Fix the usage of uprobe_buffer_enable() in probe_event_enable()
Date: Fri, 27 Jun 2014 19:01:46 +0200	[thread overview]
Message-ID: <20140627170146.GA18332@redhat.com> (raw)
In-Reply-To: <20140627170116.GA18298@redhat.com>

The usage of uprobe_buffer_enable() added by dcad1a20 is very wrong,

1. uprobe_buffer_enable() and uprobe_buffer_disable() are not balanced,
   _enable() should be called only if !enabled.

2. If uprobe_buffer_enable() fails probe_event_enable() should clear
   tp.flags and free event_file_link.

3. If uprobe_register() fails it should do uprobe_buffer_disable().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/trace/trace_uprobe.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index c4cf0ab..3c9b97e 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -911,26 +911,33 @@ probe_event_enable(struct trace_uprobe *tu, struct ftrace_event_file *file,
 		tu->tp.flags |= TP_FLAG_PROFILE;
 	}
 
-	ret = uprobe_buffer_enable();
-	if (ret < 0)
-		return ret;
-
 	WARN_ON(!uprobe_filter_is_empty(&tu->filter));
 
 	if (enabled)
 		return 0;
 
+	ret = uprobe_buffer_enable();
+	if (ret)
+		goto err_flags;
+
 	tu->consumer.filter = filter;
 	ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
-	if (ret) {
-		if (file) {
-			list_del(&link->list);
-			kfree(link);
-			tu->tp.flags &= ~TP_FLAG_TRACE;
-		} else
-			tu->tp.flags &= ~TP_FLAG_PROFILE;
-	}
+	if (ret)
+		goto err_buffer;
 
+	return 0;
+
+ err_buffer:
+	uprobe_buffer_disable();
+
+ err_flags:
+	if (file) {
+		list_del(&link->list);
+		kfree(link);
+		tu->tp.flags &= ~TP_FLAG_TRACE;
+	} else {
+		tu->tp.flags &= ~TP_FLAG_PROFILE;
+	}
 	return ret;
 }
 
-- 
1.5.5.1


  parent reply	other threads:[~2014-06-27 18:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 17:01 [PATCH 0/4] tracing/uprobes fixes Oleg Nesterov
2014-06-27 17:01 ` [PATCH 1/4] tracing/uprobes: Revert "Support mix of ftrace and perf" Oleg Nesterov
2014-06-30  5:49   ` Namhyung Kim
2014-06-30 18:48     ` Oleg Nesterov
2014-07-01 19:31       ` probe_event_disable()->synchronize_sched() (Was: tracing/uprobes: Revert "Support mix of ftrace and perf") Oleg Nesterov
2014-07-03  0:54         ` probe_event_disable()->synchronize_sched() Namhyung Kim
2014-07-03 15:41           ` probe_event_disable()->synchronize_sched() Oleg Nesterov
2014-07-03  5:35         ` probe_event_disable()->synchronize_sched() (Was: tracing/uprobes: Revert "Support mix of ftrace and perf") Masami Hiramatsu
2014-07-03  5:46         ` Masami Hiramatsu
2014-07-03  7:44           ` probe_event_disable()->synchronize_sched() Namhyung Kim
2014-07-04  1:00             ` probe_event_disable()->synchronize_sched() Masami Hiramatsu
2014-07-04  8:01               ` probe_event_disable()->synchronize_sched() Namhyung Kim
2014-07-03 16:22           ` probe_event_disable()->synchronize_sched() (Was: tracing/uprobes: Revert "Support mix of ftrace and perf") Oleg Nesterov
2014-07-03 17:01             ` __trace_remove_event_dirs() leaks file->filter ? (Was: probe_event_disable()->synchronize_sched()) Oleg Nesterov
2014-07-04  5:21               ` Masami Hiramatsu
2014-07-04 19:38                 ` Oleg Nesterov
2014-07-04  4:46             ` probe_event_disable()->synchronize_sched() (Was: tracing/uprobes: Revert "Support mix of ftrace and perf") Masami Hiramatsu
2014-06-30 11:52   ` [PATCH 1/4] tracing/uprobes: Revert "Support mix of ftrace and perf" Masami Hiramatsu
2014-06-30 16:56   ` Srikar Dronamraju
2014-06-27 17:01 ` [PATCH 2/4] uprobes: Change unregister/apply to WARN() if uprobe/consumer is gone Oleg Nesterov
2014-06-30  5:50   ` Namhyung Kim
2014-06-30 16:57   ` Srikar Dronamraju
2014-06-27 17:01 ` [PATCH 3/4] tracing/uprobes: Kill the bogus UPROBE_HANDLER_REMOVE code in uprobe_dispatcher() Oleg Nesterov
2014-06-30  6:03   ` Namhyung Kim
2014-06-30 16:57   ` Srikar Dronamraju
2014-06-27 17:01 ` Oleg Nesterov [this message]
2014-06-30  6:18   ` [PATCH 4/4] tracing/uprobes: Fix the usage of uprobe_buffer_enable() in probe_event_enable() Namhyung Kim
2014-06-30 11:49   ` Masami Hiramatsu
2014-06-30 17:04   ` Srikar Dronamraju
2014-06-30 17:21     ` Steven Rostedt
2014-06-30 17:58       ` Oleg Nesterov
2014-06-30 18:22         ` Steven Rostedt
2014-06-30 17:50     ` Oleg Nesterov
2014-06-30 18:01       ` Steven Rostedt
2014-06-30 13:28 ` [PATCH 0/4] tracing/uprobes fixes Steven Rostedt

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=20140627170146.GA18332@redhat.com \
    --to=oleg@redhat.com \
    --cc=jovi.zhangwei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tom.zanussi@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.