History

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf session: Make events_stats u64 to avoid overflow on 32-bit arches hw-breakpoints: Fix hardware breakpoints -> perf events dependency perf events: Dont report side-band events on each cpu for per-task-per-cpu events perf events, x86/stacktrace: Fix performance/softlockup by providing a special frame pointer-only stack walker perf events, x86/stacktrace: Make stack walking optional perf events: Remove unused perf_counter.h header file perf probe: Check new event name kprobe-tracer: Check new event/group name perf probe: Check whether debugfs path is correct perf probe: Fix libdwarf include path for Debian

Linus Torvalds committed 16 years ago

Commit eca9dfc2 parents 3981e15 b5b60fd20 files · +175 −523Browse files

Showing the changes to kernel/trace (2 of 20 files). Show all

Unified · Split

2 files
  1. kernel/trace/trace_kprobe.c +25 −6
  2. kernel/trace/trace_sysprof.c +1 −0
kernel/trace/trace_kprobe.c+25−6
@@ -282,6 +282,18 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); · 281 unmodified lines
282282 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
283283 struct pt_regs *regs);
284284
285+/* Check the name is good for event/group */
286+static int check_event_name(const char *name)
287+{
288+ if (!isalpha(*name) && *name != '_')
289+ return 0;
290+ while (*++name != '\0') {
291+ if (!isalpha(*name) && !isdigit(*name) && *name != '_')
292+ return 0;
293+ }
294+ return 1;
295+}
296+
285297 /*
286298 * Allocate new trace_probe and initialize it (including kprobes).
287299 */
@@ -293,10 +305,11 @@ static struct trace_probe *alloc_trace_probe(const char *group, · 5 unmodified lines
293305 int nargs, int is_return)
294306 {
295307 struct trace_probe *tp;
308+ int ret = -ENOMEM;
296309
297310 tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
298311 if (!tp)
299− return ERR_PTR(-ENOMEM);
312+ return ERR_PTR(ret);
300313
301314 if (symbol) {
302315 tp->symbol = kstrdup(symbol, GFP_KERNEL);
@@ -312,14 +325,20 @@ static struct trace_probe *alloc_trace_probe(const char *group, · 9 unmodified lines
312325 else
313326 tp->rp.kp.pre_handler = kprobe_dispatcher;
314327
315− if (!event)
328+ if (!event || !check_event_name(event)) {
329+ ret = -EINVAL;
316330 goto error;
331+ }
332+
317333 tp->call.name = kstrdup(event, GFP_KERNEL);
318334 if (!tp->call.name)
319335 goto error;
320336
321− if (!group)
337+ if (!group || !check_event_name(group)) {
338+ ret = -EINVAL;
322339 goto error;
340+ }
341+
323342 tp->call.system = kstrdup(group, GFP_KERNEL);
324343 if (!tp->call.system)
325344 goto error;
@@ -330,7 +349,7 @@ error: · 4 unmodified lines
330349 kfree(tp->call.name);
331350 kfree(tp->symbol);
332351 kfree(tp);
333− return ERR_PTR(-ENOMEM);
352+ return ERR_PTR(ret);
334353 }
335354
336355 static void free_probe_arg(struct probe_arg *arg)
@@ -695,10 +714,10 @@ static int create_trace_probe(int argc, char **argv) · 358 unmodified lines
695714 if (!event) {
696715 /* Make a new event name */
697716 if (symbol)
698− snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld",
717+ snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld",
699718 is_return ? 'r' : 'p', symbol, offset);
700719 else
701− snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p",
720+ snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p",
702721 is_return ? 'r' : 'p', addr);
703722 event = buf;
704723 }
kernel/trace/trace_sysprof.c+1−0
@@ -93,6 +93,7 @@ static const struct stacktrace_ops backtrace_ops = { · 92 unmodified lines
9393 .warning_symbol = backtrace_warning_symbol,
9494 .stack = backtrace_stack,
9595 .address = backtrace_address,
96+ .walk_stack = print_context_stack,
9697 };
9798
9899 static int