aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/bpf_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/bpf_trace.c')
-rw-r--r--kernel/trace/bpf_trace.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 9d3ec8253131..97c46b440cd6 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -479,7 +479,7 @@ static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func
479 479
480/* bpf+kprobe programs can access fields of 'struct pt_regs' */ 480/* bpf+kprobe programs can access fields of 'struct pt_regs' */
481static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type, 481static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type,
482 enum bpf_reg_type *reg_type, int *ctx_field_size) 482 struct bpf_insn_access_aux *info)
483{ 483{
484 if (off < 0 || off >= sizeof(struct pt_regs)) 484 if (off < 0 || off >= sizeof(struct pt_regs))
485 return false; 485 return false;
@@ -562,7 +562,7 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id)
562} 562}
563 563
564static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type, 564static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type,
565 enum bpf_reg_type *reg_type, int *ctx_field_size) 565 struct bpf_insn_access_aux *info)
566{ 566{
567 if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE) 567 if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE)
568 return false; 568 return false;
@@ -581,7 +581,7 @@ const struct bpf_verifier_ops tracepoint_prog_ops = {
581}; 581};
582 582
583static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type, 583static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type,
584 enum bpf_reg_type *reg_type, int *ctx_field_size) 584 struct bpf_insn_access_aux *info)
585{ 585{
586 int sample_period_off; 586 int sample_period_off;
587 587
@@ -595,12 +595,17 @@ static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type
595 /* permit 1, 2, 4 byte narrower and 8 normal read access to sample_period */ 595 /* permit 1, 2, 4 byte narrower and 8 normal read access to sample_period */
596 sample_period_off = offsetof(struct bpf_perf_event_data, sample_period); 596 sample_period_off = offsetof(struct bpf_perf_event_data, sample_period);
597 if (off >= sample_period_off && off < sample_period_off + sizeof(__u64)) { 597 if (off >= sample_period_off && off < sample_period_off + sizeof(__u64)) {
598 *ctx_field_size = 8; 598 int allowed;
599
599#ifdef __LITTLE_ENDIAN 600#ifdef __LITTLE_ENDIAN
600 return (off & 0x7) == 0 && size <= 8 && (size & (size - 1)) == 0; 601 allowed = (off & 0x7) == 0 && size <= 8 && (size & (size - 1)) == 0;
601#else 602#else
602 return ((off & 0x7) + size) == 8 && size <= 8 && (size & (size - 1)) == 0; 603 allowed = ((off & 0x7) + size) == 8 && size <= 8 && (size & (size - 1)) == 0;
603#endif 604#endif
605 if (!allowed)
606 return false;
607 info->ctx_field_size = 8;
608 info->converted_op_size = 8;
604 } else { 609 } else {
605 if (size != sizeof(long)) 610 if (size != sizeof(long))
606 return false; 611 return false;