Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-fixes-v3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:
"This includes a fix to a memory leak when adding filters to traces.

Also, Masami Hiramatsu fixed up some minor bugs that were discovered
by sparse."

* tag 'trace-fixes-v3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing/kprobes: Make print_*probe_event static
tracing/kprobes: Fix a sparse warning for incorrect type in assignment
tracing/kprobes: Use rcu_dereference_raw for tp->files
tracing: Fix leaks of filter preds

+44 -13
+4
kernel/trace/trace_events_filter.c
··· 750 750 751 751 static void __free_preds(struct event_filter *filter) 752 752 { 753 + int i; 754 + 753 755 if (filter->preds) { 756 + for (i = 0; i < filter->n_preds; i++) 757 + kfree(filter->preds[i].ops); 754 758 kfree(filter->preds); 755 759 filter->preds = NULL; 756 760 }
+40 -13
kernel/trace/trace_kprobe.c
··· 35 35 const char *symbol; /* symbol name */ 36 36 struct ftrace_event_class class; 37 37 struct ftrace_event_call call; 38 - struct ftrace_event_file **files; 38 + struct ftrace_event_file * __rcu *files; 39 39 ssize_t size; /* trace entry size */ 40 40 unsigned int nr_args; 41 41 struct probe_arg args[]; ··· 185 185 186 186 static int trace_probe_nr_files(struct trace_probe *tp) 187 187 { 188 - struct ftrace_event_file **file = tp->files; 188 + struct ftrace_event_file **file; 189 189 int ret = 0; 190 190 191 + /* 192 + * Since all tp->files updater is protected by probe_enable_lock, 193 + * we don't need to lock an rcu_read_lock. 194 + */ 195 + file = rcu_dereference_raw(tp->files); 191 196 if (file) 192 197 while (*(file++)) 193 198 ret++; ··· 214 209 mutex_lock(&probe_enable_lock); 215 210 216 211 if (file) { 217 - struct ftrace_event_file **new, **old = tp->files; 212 + struct ftrace_event_file **new, **old; 218 213 int n = trace_probe_nr_files(tp); 219 214 215 + old = rcu_dereference_raw(tp->files); 220 216 /* 1 is for new one and 1 is for stopper */ 221 217 new = kzalloc((n + 2) * sizeof(struct ftrace_event_file *), 222 218 GFP_KERNEL); ··· 257 251 static int 258 252 trace_probe_file_index(struct trace_probe *tp, struct ftrace_event_file *file) 259 253 { 254 + struct ftrace_event_file **files; 260 255 int i; 261 256 262 - if (tp->files) { 263 - for (i = 0; tp->files[i]; i++) 264 - if (tp->files[i] == file) 257 + /* 258 + * Since all tp->files updater is protected by probe_enable_lock, 259 + * we don't need to lock an rcu_read_lock. 260 + */ 261 + files = rcu_dereference_raw(tp->files); 262 + if (files) { 263 + for (i = 0; files[i]; i++) 264 + if (files[i] == file) 265 265 return i; 266 266 } 267 267 ··· 286 274 mutex_lock(&probe_enable_lock); 287 275 288 276 if (file) { 289 - struct ftrace_event_file **new, **old = tp->files; 277 + struct ftrace_event_file **new, **old; 290 278 int n = trace_probe_nr_files(tp); 291 279 int i, j; 292 280 281 + old = rcu_dereference_raw(tp->files); 293 282 if (n == 0 || trace_probe_file_index(tp, file) < 0) { 294 283 ret = -EINVAL; 295 284 goto out_unlock; ··· 885 872 static __kprobes void 886 873 kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs) 887 874 { 888 - struct ftrace_event_file **file = tp->files; 875 + /* 876 + * Note: preempt is already disabled around the kprobe handler. 877 + * However, we still need an smp_read_barrier_depends() corresponding 878 + * to smp_wmb() in rcu_assign_pointer() to access the pointer. 879 + */ 880 + struct ftrace_event_file **file = rcu_dereference_raw(tp->files); 889 881 890 - /* Note: preempt is already disabled around the kprobe handler */ 882 + if (unlikely(!file)) 883 + return; 884 + 891 885 while (*file) { 892 886 __kprobe_trace_func(tp, regs, *file); 893 887 file++; ··· 945 925 kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri, 946 926 struct pt_regs *regs) 947 927 { 948 - struct ftrace_event_file **file = tp->files; 928 + /* 929 + * Note: preempt is already disabled around the kprobe handler. 930 + * However, we still need an smp_read_barrier_depends() corresponding 931 + * to smp_wmb() in rcu_assign_pointer() to access the pointer. 932 + */ 933 + struct ftrace_event_file **file = rcu_dereference_raw(tp->files); 949 934 950 - /* Note: preempt is already disabled around the kprobe handler */ 935 + if (unlikely(!file)) 936 + return; 937 + 951 938 while (*file) { 952 939 __kretprobe_trace_func(tp, ri, regs, *file); 953 940 file++; ··· 962 935 } 963 936 964 937 /* Event entry printers */ 965 - enum print_line_t 938 + static enum print_line_t 966 939 print_kprobe_event(struct trace_iterator *iter, int flags, 967 940 struct trace_event *event) 968 941 { ··· 998 971 return TRACE_TYPE_PARTIAL_LINE; 999 972 } 1000 973 1001 - enum print_line_t 974 + static enum print_line_t 1002 975 print_kretprobe_event(struct trace_iterator *iter, int flags, 1003 976 struct trace_event *event) 1004 977 {