diff options
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
| -rw-r--r-- | kernel/trace/trace_kprobe.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index d73f565b4e06..d0ce590f06e1 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
| @@ -250,7 +250,7 @@ DEFINE_FETCH_symbol(string_size) | |||
| 250 | #define fetch_file_offset_string_size NULL | 250 | #define fetch_file_offset_string_size NULL |
| 251 | 251 | ||
| 252 | /* Fetch type information table */ | 252 | /* Fetch type information table */ |
| 253 | const struct fetch_type kprobes_fetch_type_table[] = { | 253 | static const struct fetch_type kprobes_fetch_type_table[] = { |
| 254 | /* Special types */ | 254 | /* Special types */ |
| 255 | [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string, | 255 | [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string, |
| 256 | sizeof(u32), 1, "__data_loc char[]"), | 256 | sizeof(u32), 1, "__data_loc char[]"), |
| @@ -760,7 +760,8 @@ static int create_trace_kprobe(int argc, char **argv) | |||
| 760 | 760 | ||
| 761 | /* Parse fetch argument */ | 761 | /* Parse fetch argument */ |
| 762 | ret = traceprobe_parse_probe_arg(arg, &tk->tp.size, parg, | 762 | ret = traceprobe_parse_probe_arg(arg, &tk->tp.size, parg, |
| 763 | is_return, true); | 763 | is_return, true, |
| 764 | kprobes_fetch_type_table); | ||
| 764 | if (ret) { | 765 | if (ret) { |
| 765 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); | 766 | pr_info("Parse error at argument[%d]. (%d)\n", i, ret); |
| 766 | goto error; | 767 | goto error; |
| @@ -1134,11 +1135,15 @@ static void | |||
| 1134 | kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) | 1135 | kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) |
| 1135 | { | 1136 | { |
| 1136 | struct ftrace_event_call *call = &tk->tp.call; | 1137 | struct ftrace_event_call *call = &tk->tp.call; |
| 1138 | struct bpf_prog *prog = call->prog; | ||
| 1137 | struct kprobe_trace_entry_head *entry; | 1139 | struct kprobe_trace_entry_head *entry; |
| 1138 | struct hlist_head *head; | 1140 | struct hlist_head *head; |
| 1139 | int size, __size, dsize; | 1141 | int size, __size, dsize; |
| 1140 | int rctx; | 1142 | int rctx; |
| 1141 | 1143 | ||
| 1144 | if (prog && !trace_call_bpf(prog, regs)) | ||
| 1145 | return; | ||
| 1146 | |||
| 1142 | head = this_cpu_ptr(call->perf_events); | 1147 | head = this_cpu_ptr(call->perf_events); |
| 1143 | if (hlist_empty(head)) | 1148 | if (hlist_empty(head)) |
| 1144 | return; | 1149 | return; |
| @@ -1165,11 +1170,15 @@ kretprobe_perf_func(struct trace_kprobe *tk, struct kretprobe_instance *ri, | |||
| 1165 | struct pt_regs *regs) | 1170 | struct pt_regs *regs) |
| 1166 | { | 1171 | { |
| 1167 | struct ftrace_event_call *call = &tk->tp.call; | 1172 | struct ftrace_event_call *call = &tk->tp.call; |
| 1173 | struct bpf_prog *prog = call->prog; | ||
| 1168 | struct kretprobe_trace_entry_head *entry; | 1174 | struct kretprobe_trace_entry_head *entry; |
| 1169 | struct hlist_head *head; | 1175 | struct hlist_head *head; |
| 1170 | int size, __size, dsize; | 1176 | int size, __size, dsize; |
| 1171 | int rctx; | 1177 | int rctx; |
| 1172 | 1178 | ||
| 1179 | if (prog && !trace_call_bpf(prog, regs)) | ||
| 1180 | return; | ||
| 1181 | |||
| 1173 | head = this_cpu_ptr(call->perf_events); | 1182 | head = this_cpu_ptr(call->perf_events); |
| 1174 | if (hlist_empty(head)) | 1183 | if (hlist_empty(head)) |
| 1175 | return; | 1184 | return; |
| @@ -1286,7 +1295,7 @@ static int register_kprobe_event(struct trace_kprobe *tk) | |||
| 1286 | kfree(call->print_fmt); | 1295 | kfree(call->print_fmt); |
| 1287 | return -ENODEV; | 1296 | return -ENODEV; |
| 1288 | } | 1297 | } |
| 1289 | call->flags = 0; | 1298 | call->flags = TRACE_EVENT_FL_KPROBE; |
| 1290 | call->class->reg = kprobe_register; | 1299 | call->class->reg = kprobe_register; |
| 1291 | call->data = tk; | 1300 | call->data = tk; |
| 1292 | ret = trace_add_event_call(call); | 1301 | ret = trace_add_event_call(call); |
| @@ -1310,7 +1319,7 @@ static int unregister_kprobe_event(struct trace_kprobe *tk) | |||
| 1310 | return ret; | 1319 | return ret; |
| 1311 | } | 1320 | } |
| 1312 | 1321 | ||
| 1313 | /* Make a debugfs interface for controlling probe points */ | 1322 | /* Make a tracefs interface for controlling probe points */ |
| 1314 | static __init int init_kprobe_trace(void) | 1323 | static __init int init_kprobe_trace(void) |
| 1315 | { | 1324 | { |
| 1316 | struct dentry *d_tracer; | 1325 | struct dentry *d_tracer; |
| @@ -1323,20 +1332,20 @@ static __init int init_kprobe_trace(void) | |||
| 1323 | if (IS_ERR(d_tracer)) | 1332 | if (IS_ERR(d_tracer)) |
| 1324 | return 0; | 1333 | return 0; |
| 1325 | 1334 | ||
| 1326 | entry = debugfs_create_file("kprobe_events", 0644, d_tracer, | 1335 | entry = tracefs_create_file("kprobe_events", 0644, d_tracer, |
| 1327 | NULL, &kprobe_events_ops); | 1336 | NULL, &kprobe_events_ops); |
| 1328 | 1337 | ||
| 1329 | /* Event list interface */ | 1338 | /* Event list interface */ |
| 1330 | if (!entry) | 1339 | if (!entry) |
| 1331 | pr_warning("Could not create debugfs " | 1340 | pr_warning("Could not create tracefs " |
| 1332 | "'kprobe_events' entry\n"); | 1341 | "'kprobe_events' entry\n"); |
| 1333 | 1342 | ||
| 1334 | /* Profile interface */ | 1343 | /* Profile interface */ |
| 1335 | entry = debugfs_create_file("kprobe_profile", 0444, d_tracer, | 1344 | entry = tracefs_create_file("kprobe_profile", 0444, d_tracer, |
| 1336 | NULL, &kprobe_profile_ops); | 1345 | NULL, &kprobe_profile_ops); |
| 1337 | 1346 | ||
| 1338 | if (!entry) | 1347 | if (!entry) |
| 1339 | pr_warning("Could not create debugfs " | 1348 | pr_warning("Could not create tracefs " |
| 1340 | "'kprobe_profile' entry\n"); | 1349 | "'kprobe_profile' entry\n"); |
| 1341 | return 0; | 1350 | return 0; |
| 1342 | } | 1351 | } |
