diff options
Diffstat (limited to 'kernel/trace/bpf_trace.c')
-rw-r--r-- | kernel/trace/bpf_trace.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 037ea6ea3cb2..3de25fbed785 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c | |||
@@ -208,6 +208,10 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5) | |||
208 | event->pmu->count) | 208 | event->pmu->count) |
209 | return -EINVAL; | 209 | return -EINVAL; |
210 | 210 | ||
211 | if (unlikely(event->attr.type != PERF_TYPE_HARDWARE && | ||
212 | event->attr.type != PERF_TYPE_RAW)) | ||
213 | return -EINVAL; | ||
214 | |||
211 | /* | 215 | /* |
212 | * we don't know if the function is run successfully by the | 216 | * we don't know if the function is run successfully by the |
213 | * return value. It can be judged in other places, such as | 217 | * return value. It can be judged in other places, such as |
@@ -347,7 +351,8 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func | |||
347 | } | 351 | } |
348 | 352 | ||
349 | /* bpf+kprobe programs can access fields of 'struct pt_regs' */ | 353 | /* bpf+kprobe programs can access fields of 'struct pt_regs' */ |
350 | static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type) | 354 | static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type, |
355 | enum bpf_reg_type *reg_type) | ||
351 | { | 356 | { |
352 | /* check bounds */ | 357 | /* check bounds */ |
353 | if (off < 0 || off >= sizeof(struct pt_regs)) | 358 | if (off < 0 || off >= sizeof(struct pt_regs)) |
@@ -425,7 +430,8 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id) | |||
425 | } | 430 | } |
426 | } | 431 | } |
427 | 432 | ||
428 | static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type) | 433 | static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type, |
434 | enum bpf_reg_type *reg_type) | ||
429 | { | 435 | { |
430 | if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE) | 436 | if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE) |
431 | return false; | 437 | return false; |