@@ -268,7 +268,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto = {
268
268
.arg5_type = ARG_CONST_STACK_SIZE ,
269
269
};
270
270
271
- static const struct bpf_func_proto * kprobe_prog_func_proto (enum bpf_func_id func_id )
271
+ static const struct bpf_func_proto * tracing_func_proto (enum bpf_func_id func_id )
272
272
{
273
273
switch (func_id ) {
274
274
case BPF_FUNC_map_lookup_elem :
@@ -295,12 +295,20 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func
295
295
return & bpf_get_smp_processor_id_proto ;
296
296
case BPF_FUNC_perf_event_read :
297
297
return & bpf_perf_event_read_proto ;
298
+ default :
299
+ return NULL ;
300
+ }
301
+ }
302
+
303
+ static const struct bpf_func_proto * kprobe_prog_func_proto (enum bpf_func_id func_id )
304
+ {
305
+ switch (func_id ) {
298
306
case BPF_FUNC_perf_event_output :
299
307
return & bpf_perf_event_output_proto ;
300
308
case BPF_FUNC_get_stackid :
301
309
return & bpf_get_stackid_proto ;
302
310
default :
303
- return NULL ;
311
+ return tracing_func_proto ( func_id ) ;
304
312
}
305
313
}
306
314
@@ -332,9 +340,42 @@ static struct bpf_prog_type_list kprobe_tl = {
332
340
.type = BPF_PROG_TYPE_KPROBE ,
333
341
};
334
342
343
+ static const struct bpf_func_proto * tp_prog_func_proto (enum bpf_func_id func_id )
344
+ {
345
+ switch (func_id ) {
346
+ case BPF_FUNC_perf_event_output :
347
+ case BPF_FUNC_get_stackid :
348
+ return NULL ;
349
+ default :
350
+ return tracing_func_proto (func_id );
351
+ }
352
+ }
353
+
354
+ static bool tp_prog_is_valid_access (int off , int size , enum bpf_access_type type )
355
+ {
356
+ if (off < sizeof (void * ) || off >= PERF_MAX_TRACE_SIZE )
357
+ return false;
358
+ if (type != BPF_READ )
359
+ return false;
360
+ if (off % size != 0 )
361
+ return false;
362
+ return true;
363
+ }
364
+
365
+ static const struct bpf_verifier_ops tracepoint_prog_ops = {
366
+ .get_func_proto = tp_prog_func_proto ,
367
+ .is_valid_access = tp_prog_is_valid_access ,
368
+ };
369
+
370
+ static struct bpf_prog_type_list tracepoint_tl = {
371
+ .ops = & tracepoint_prog_ops ,
372
+ .type = BPF_PROG_TYPE_TRACEPOINT ,
373
+ };
374
+
335
375
static int __init register_kprobe_prog_ops (void )
336
376
{
337
377
bpf_register_prog_type (& kprobe_tl );
378
+ bpf_register_prog_type (& tracepoint_tl );
338
379
return 0 ;
339
380
}
340
381
late_initcall (register_kprobe_prog_ops );
0 commit comments