Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2015 PLUMgrid, http://plumgrid.com |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016 Facebook |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of version 2 of the GNU General Public |
| 6 | * License as published by the Free Software Foundation. |
| 7 | */ |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/types.h> |
| 10 | #include <linux/slab.h> |
| 11 | #include <linux/bpf.h> |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 12 | #include <linux/bpf_perf_event.h> |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 13 | #include <linux/filter.h> |
| 14 | #include <linux/uaccess.h> |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 15 | #include <linux/ctype.h> |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 16 | #include "trace.h" |
| 17 | |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 18 | /** |
| 19 | * trace_call_bpf - invoke BPF program |
| 20 | * @prog: BPF program |
| 21 | * @ctx: opaque context pointer |
| 22 | * |
| 23 | * kprobe handlers execute BPF programs via this helper. |
| 24 | * Can be used from static tracepoints in the future. |
| 25 | * |
| 26 | * Return: BPF programs always return an integer which is interpreted by |
| 27 | * kprobe handler as: |
| 28 | * 0 - return from kprobe (event is filtered out) |
| 29 | * 1 - store kprobe event into ring buffer |
| 30 | * Other values are reserved and currently alias to 1 |
| 31 | */ |
| 32 | unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx) |
| 33 | { |
| 34 | unsigned int ret; |
| 35 | |
| 36 | if (in_nmi()) /* not supported yet */ |
| 37 | return 1; |
| 38 | |
| 39 | preempt_disable(); |
| 40 | |
| 41 | if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) { |
| 42 | /* |
| 43 | * since some bpf program is already running on this cpu, |
| 44 | * don't call into another bpf program (same or different) |
| 45 | * and don't send kprobe event into ring-buffer, |
| 46 | * so return zero here |
| 47 | */ |
| 48 | ret = 0; |
| 49 | goto out; |
| 50 | } |
| 51 | |
| 52 | rcu_read_lock(); |
| 53 | ret = BPF_PROG_RUN(prog, ctx); |
| 54 | rcu_read_unlock(); |
| 55 | |
| 56 | out: |
| 57 | __this_cpu_dec(bpf_prog_active); |
| 58 | preempt_enable(); |
| 59 | |
| 60 | return ret; |
| 61 | } |
| 62 | EXPORT_SYMBOL_GPL(trace_call_bpf); |
| 63 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 64 | BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, const void *, unsafe_ptr) |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 65 | { |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 66 | int ret; |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 67 | |
Daniel Borkmann | 074f528e | 2016-04-13 00:10:52 +0200 | [diff] [blame] | 68 | ret = probe_kernel_read(dst, unsafe_ptr, size); |
| 69 | if (unlikely(ret < 0)) |
| 70 | memset(dst, 0, size); |
| 71 | |
| 72 | return ret; |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static const struct bpf_func_proto bpf_probe_read_proto = { |
| 76 | .func = bpf_probe_read, |
| 77 | .gpl_only = true, |
| 78 | .ret_type = RET_INTEGER, |
Alexei Starovoitov | 39f19ebb | 2017-01-09 10:19:50 -0800 | [diff] [blame] | 79 | .arg1_type = ARG_PTR_TO_UNINIT_MEM, |
| 80 | .arg2_type = ARG_CONST_SIZE, |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 81 | .arg3_type = ARG_ANYTHING, |
| 82 | }; |
| 83 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 84 | BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, |
| 85 | u32, size) |
Sargun Dhillon | 96ae522 | 2016-07-25 05:54:46 -0700 | [diff] [blame] | 86 | { |
Sargun Dhillon | 96ae522 | 2016-07-25 05:54:46 -0700 | [diff] [blame] | 87 | /* |
| 88 | * Ensure we're in user context which is safe for the helper to |
| 89 | * run. This helper has no business in a kthread. |
| 90 | * |
| 91 | * access_ok() should prevent writing to non-user memory, but in |
| 92 | * some situations (nommu, temporary switch, etc) access_ok() does |
| 93 | * not provide enough validation, hence the check on KERNEL_DS. |
| 94 | */ |
| 95 | |
| 96 | if (unlikely(in_interrupt() || |
| 97 | current->flags & (PF_KTHREAD | PF_EXITING))) |
| 98 | return -EPERM; |
Al Viro | db68ce1 | 2017-03-20 21:08:07 -0400 | [diff] [blame] | 99 | if (unlikely(uaccess_kernel())) |
Sargun Dhillon | 96ae522 | 2016-07-25 05:54:46 -0700 | [diff] [blame] | 100 | return -EPERM; |
| 101 | if (!access_ok(VERIFY_WRITE, unsafe_ptr, size)) |
| 102 | return -EPERM; |
| 103 | |
| 104 | return probe_kernel_write(unsafe_ptr, src, size); |
| 105 | } |
| 106 | |
| 107 | static const struct bpf_func_proto bpf_probe_write_user_proto = { |
| 108 | .func = bpf_probe_write_user, |
| 109 | .gpl_only = true, |
| 110 | .ret_type = RET_INTEGER, |
| 111 | .arg1_type = ARG_ANYTHING, |
Alexei Starovoitov | 39f19ebb | 2017-01-09 10:19:50 -0800 | [diff] [blame] | 112 | .arg2_type = ARG_PTR_TO_MEM, |
| 113 | .arg3_type = ARG_CONST_SIZE, |
Sargun Dhillon | 96ae522 | 2016-07-25 05:54:46 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | static const struct bpf_func_proto *bpf_get_probe_write_proto(void) |
| 117 | { |
| 118 | pr_warn_ratelimited("%s[%d] is installing a program with bpf_probe_write_user helper that may corrupt user memory!", |
| 119 | current->comm, task_pid_nr(current)); |
| 120 | |
| 121 | return &bpf_probe_write_user_proto; |
| 122 | } |
| 123 | |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 124 | /* |
| 125 | * limited trace_printk() |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 126 | * only %d %u %x %ld %lu %lx %lld %llu %llx %p %s conversion specifiers allowed |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 127 | */ |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 128 | BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, |
| 129 | u64, arg2, u64, arg3) |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 130 | { |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 131 | bool str_seen = false; |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 132 | int mod[3] = {}; |
| 133 | int fmt_cnt = 0; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 134 | u64 unsafe_addr; |
| 135 | char buf[64]; |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 136 | int i; |
| 137 | |
| 138 | /* |
| 139 | * bpf_check()->check_func_arg()->check_stack_boundary() |
| 140 | * guarantees that fmt points to bpf program stack, |
| 141 | * fmt_size bytes of it were initialized and fmt_size > 0 |
| 142 | */ |
| 143 | if (fmt[--fmt_size] != 0) |
| 144 | return -EINVAL; |
| 145 | |
| 146 | /* check format string for allowed specifiers */ |
| 147 | for (i = 0; i < fmt_size; i++) { |
| 148 | if ((!isprint(fmt[i]) && !isspace(fmt[i])) || !isascii(fmt[i])) |
| 149 | return -EINVAL; |
| 150 | |
| 151 | if (fmt[i] != '%') |
| 152 | continue; |
| 153 | |
| 154 | if (fmt_cnt >= 3) |
| 155 | return -EINVAL; |
| 156 | |
| 157 | /* fmt[i] != 0 && fmt[last] == 0, so we can access fmt[i + 1] */ |
| 158 | i++; |
| 159 | if (fmt[i] == 'l') { |
| 160 | mod[fmt_cnt]++; |
| 161 | i++; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 162 | } else if (fmt[i] == 'p' || fmt[i] == 's') { |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 163 | mod[fmt_cnt]++; |
| 164 | i++; |
| 165 | if (!isspace(fmt[i]) && !ispunct(fmt[i]) && fmt[i] != 0) |
| 166 | return -EINVAL; |
| 167 | fmt_cnt++; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 168 | if (fmt[i - 1] == 's') { |
| 169 | if (str_seen) |
| 170 | /* allow only one '%s' per fmt string */ |
| 171 | return -EINVAL; |
| 172 | str_seen = true; |
| 173 | |
| 174 | switch (fmt_cnt) { |
| 175 | case 1: |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 176 | unsafe_addr = arg1; |
| 177 | arg1 = (long) buf; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 178 | break; |
| 179 | case 2: |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 180 | unsafe_addr = arg2; |
| 181 | arg2 = (long) buf; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 182 | break; |
| 183 | case 3: |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 184 | unsafe_addr = arg3; |
| 185 | arg3 = (long) buf; |
Alexei Starovoitov | 8d3b7dc | 2015-08-28 15:56:23 -0700 | [diff] [blame] | 186 | break; |
| 187 | } |
| 188 | buf[0] = 0; |
| 189 | strncpy_from_unsafe(buf, |
| 190 | (void *) (long) unsafe_addr, |
| 191 | sizeof(buf)); |
| 192 | } |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 193 | continue; |
| 194 | } |
| 195 | |
| 196 | if (fmt[i] == 'l') { |
| 197 | mod[fmt_cnt]++; |
| 198 | i++; |
| 199 | } |
| 200 | |
| 201 | if (fmt[i] != 'd' && fmt[i] != 'u' && fmt[i] != 'x') |
| 202 | return -EINVAL; |
| 203 | fmt_cnt++; |
| 204 | } |
| 205 | |
| 206 | return __trace_printk(1/* fake ip will not be printed */, fmt, |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 207 | mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1, |
| 208 | mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2, |
| 209 | mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3); |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | static const struct bpf_func_proto bpf_trace_printk_proto = { |
| 213 | .func = bpf_trace_printk, |
| 214 | .gpl_only = true, |
| 215 | .ret_type = RET_INTEGER, |
Alexei Starovoitov | 39f19ebb | 2017-01-09 10:19:50 -0800 | [diff] [blame] | 216 | .arg1_type = ARG_PTR_TO_MEM, |
| 217 | .arg2_type = ARG_CONST_SIZE, |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 218 | }; |
| 219 | |
Alexei Starovoitov | 0756ea3 | 2015-06-12 19:39:13 -0700 | [diff] [blame] | 220 | const struct bpf_func_proto *bpf_get_trace_printk_proto(void) |
| 221 | { |
| 222 | /* |
| 223 | * this program might be calling bpf_trace_printk, |
| 224 | * so allocate per-cpu printk buffers |
| 225 | */ |
| 226 | trace_printk_init_buffers(); |
| 227 | |
| 228 | return &bpf_trace_printk_proto; |
| 229 | } |
| 230 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 231 | BPF_CALL_2(bpf_perf_event_read, struct bpf_map *, map, u64, flags) |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 232 | { |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 233 | struct bpf_array *array = container_of(map, struct bpf_array, map); |
Daniel Borkmann | 6816a7f | 2016-06-28 12:18:25 +0200 | [diff] [blame] | 234 | unsigned int cpu = smp_processor_id(); |
| 235 | u64 index = flags & BPF_F_INDEX_MASK; |
Daniel Borkmann | 3b1efb1 | 2016-06-15 22:47:14 +0200 | [diff] [blame] | 236 | struct bpf_event_entry *ee; |
Alexei Starovoitov | f91840a | 2017-06-02 21:03:52 -0700 | [diff] [blame^] | 237 | u64 value = 0; |
| 238 | int err; |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 239 | |
Daniel Borkmann | 6816a7f | 2016-06-28 12:18:25 +0200 | [diff] [blame] | 240 | if (unlikely(flags & ~(BPF_F_INDEX_MASK))) |
| 241 | return -EINVAL; |
| 242 | if (index == BPF_F_CURRENT_CPU) |
| 243 | index = cpu; |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 244 | if (unlikely(index >= array->map.max_entries)) |
| 245 | return -E2BIG; |
| 246 | |
Daniel Borkmann | 3b1efb1 | 2016-06-15 22:47:14 +0200 | [diff] [blame] | 247 | ee = READ_ONCE(array->ptrs[index]); |
Daniel Borkmann | 1ca1cc9 | 2016-06-28 12:18:23 +0200 | [diff] [blame] | 248 | if (!ee) |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 249 | return -ENOENT; |
| 250 | |
Alexei Starovoitov | f91840a | 2017-06-02 21:03:52 -0700 | [diff] [blame^] | 251 | err = perf_event_read_local(ee->event, &value); |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 252 | /* |
Alexei Starovoitov | f91840a | 2017-06-02 21:03:52 -0700 | [diff] [blame^] | 253 | * this api is ugly since we miss [-22..-2] range of valid |
| 254 | * counter values, but that's uapi |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 255 | */ |
Alexei Starovoitov | f91840a | 2017-06-02 21:03:52 -0700 | [diff] [blame^] | 256 | if (err) |
| 257 | return err; |
| 258 | return value; |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 259 | } |
| 260 | |
Alexei Starovoitov | 62544ce | 2015-10-22 17:10:14 -0700 | [diff] [blame] | 261 | static const struct bpf_func_proto bpf_perf_event_read_proto = { |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 262 | .func = bpf_perf_event_read, |
Alexei Starovoitov | 1075ef5 | 2015-10-23 14:58:19 -0700 | [diff] [blame] | 263 | .gpl_only = true, |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 264 | .ret_type = RET_INTEGER, |
| 265 | .arg1_type = ARG_CONST_MAP_PTR, |
| 266 | .arg2_type = ARG_ANYTHING, |
| 267 | }; |
| 268 | |
Daniel Borkmann | 8e7a392 | 2016-07-14 18:08:04 +0200 | [diff] [blame] | 269 | static __always_inline u64 |
| 270 | __bpf_perf_event_output(struct pt_regs *regs, struct bpf_map *map, |
| 271 | u64 flags, struct perf_raw_record *raw) |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 272 | { |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 273 | struct bpf_array *array = container_of(map, struct bpf_array, map); |
Daniel Borkmann | d793133 | 2016-06-28 12:18:24 +0200 | [diff] [blame] | 274 | unsigned int cpu = smp_processor_id(); |
Daniel Borkmann | 1e33759 | 2016-04-18 21:01:23 +0200 | [diff] [blame] | 275 | u64 index = flags & BPF_F_INDEX_MASK; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 276 | struct perf_sample_data sample_data; |
Daniel Borkmann | 3b1efb1 | 2016-06-15 22:47:14 +0200 | [diff] [blame] | 277 | struct bpf_event_entry *ee; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 278 | struct perf_event *event; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 279 | |
Daniel Borkmann | 1e33759 | 2016-04-18 21:01:23 +0200 | [diff] [blame] | 280 | if (index == BPF_F_CURRENT_CPU) |
Daniel Borkmann | d793133 | 2016-06-28 12:18:24 +0200 | [diff] [blame] | 281 | index = cpu; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 282 | if (unlikely(index >= array->map.max_entries)) |
| 283 | return -E2BIG; |
| 284 | |
Daniel Borkmann | 3b1efb1 | 2016-06-15 22:47:14 +0200 | [diff] [blame] | 285 | ee = READ_ONCE(array->ptrs[index]); |
Daniel Borkmann | 1ca1cc9 | 2016-06-28 12:18:23 +0200 | [diff] [blame] | 286 | if (!ee) |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 287 | return -ENOENT; |
| 288 | |
Daniel Borkmann | 3b1efb1 | 2016-06-15 22:47:14 +0200 | [diff] [blame] | 289 | event = ee->event; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 290 | if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE || |
| 291 | event->attr.config != PERF_COUNT_SW_BPF_OUTPUT)) |
| 292 | return -EINVAL; |
| 293 | |
Daniel Borkmann | d793133 | 2016-06-28 12:18:24 +0200 | [diff] [blame] | 294 | if (unlikely(event->oncpu != cpu)) |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 295 | return -EOPNOTSUPP; |
| 296 | |
| 297 | perf_sample_data_init(&sample_data, 0, 0); |
Daniel Borkmann | 8e7a392 | 2016-07-14 18:08:04 +0200 | [diff] [blame] | 298 | sample_data.raw = raw; |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 299 | perf_event_output(event, &sample_data, regs); |
| 300 | return 0; |
| 301 | } |
| 302 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 303 | BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map, |
| 304 | u64, flags, void *, data, u64, size) |
Daniel Borkmann | 8e7a392 | 2016-07-14 18:08:04 +0200 | [diff] [blame] | 305 | { |
Daniel Borkmann | 8e7a392 | 2016-07-14 18:08:04 +0200 | [diff] [blame] | 306 | struct perf_raw_record raw = { |
| 307 | .frag = { |
| 308 | .size = size, |
| 309 | .data = data, |
| 310 | }, |
| 311 | }; |
| 312 | |
| 313 | if (unlikely(flags & ~(BPF_F_INDEX_MASK))) |
| 314 | return -EINVAL; |
| 315 | |
| 316 | return __bpf_perf_event_output(regs, map, flags, &raw); |
| 317 | } |
| 318 | |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 319 | static const struct bpf_func_proto bpf_perf_event_output_proto = { |
| 320 | .func = bpf_perf_event_output, |
Alexei Starovoitov | 1075ef5 | 2015-10-23 14:58:19 -0700 | [diff] [blame] | 321 | .gpl_only = true, |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 322 | .ret_type = RET_INTEGER, |
| 323 | .arg1_type = ARG_PTR_TO_CTX, |
| 324 | .arg2_type = ARG_CONST_MAP_PTR, |
| 325 | .arg3_type = ARG_ANYTHING, |
Alexei Starovoitov | 39f19ebb | 2017-01-09 10:19:50 -0800 | [diff] [blame] | 326 | .arg4_type = ARG_PTR_TO_MEM, |
| 327 | .arg5_type = ARG_CONST_SIZE, |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 328 | }; |
| 329 | |
Daniel Borkmann | bd570ff | 2016-04-18 21:01:24 +0200 | [diff] [blame] | 330 | static DEFINE_PER_CPU(struct pt_regs, bpf_pt_regs); |
| 331 | |
Daniel Borkmann | 555c8a8 | 2016-07-14 18:08:05 +0200 | [diff] [blame] | 332 | u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size, |
| 333 | void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy) |
Daniel Borkmann | bd570ff | 2016-04-18 21:01:24 +0200 | [diff] [blame] | 334 | { |
| 335 | struct pt_regs *regs = this_cpu_ptr(&bpf_pt_regs); |
Daniel Borkmann | 555c8a8 | 2016-07-14 18:08:05 +0200 | [diff] [blame] | 336 | struct perf_raw_frag frag = { |
| 337 | .copy = ctx_copy, |
| 338 | .size = ctx_size, |
| 339 | .data = ctx, |
| 340 | }; |
| 341 | struct perf_raw_record raw = { |
| 342 | .frag = { |
Andrew Morton | 183fc15 | 2016-07-18 15:50:58 -0700 | [diff] [blame] | 343 | { |
| 344 | .next = ctx_size ? &frag : NULL, |
| 345 | }, |
Daniel Borkmann | 555c8a8 | 2016-07-14 18:08:05 +0200 | [diff] [blame] | 346 | .size = meta_size, |
| 347 | .data = meta, |
| 348 | }, |
| 349 | }; |
Daniel Borkmann | bd570ff | 2016-04-18 21:01:24 +0200 | [diff] [blame] | 350 | |
| 351 | perf_fetch_caller_regs(regs); |
| 352 | |
Daniel Borkmann | 555c8a8 | 2016-07-14 18:08:05 +0200 | [diff] [blame] | 353 | return __bpf_perf_event_output(regs, map, flags, &raw); |
Daniel Borkmann | bd570ff | 2016-04-18 21:01:24 +0200 | [diff] [blame] | 354 | } |
| 355 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 356 | BPF_CALL_0(bpf_get_current_task) |
Alexei Starovoitov | 606274c | 2016-07-06 22:38:36 -0700 | [diff] [blame] | 357 | { |
| 358 | return (long) current; |
| 359 | } |
| 360 | |
| 361 | static const struct bpf_func_proto bpf_get_current_task_proto = { |
| 362 | .func = bpf_get_current_task, |
| 363 | .gpl_only = true, |
| 364 | .ret_type = RET_INTEGER, |
| 365 | }; |
| 366 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 367 | BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx) |
Sargun Dhillon | 60d20f9 | 2016-08-12 08:56:52 -0700 | [diff] [blame] | 368 | { |
Sargun Dhillon | 60d20f9 | 2016-08-12 08:56:52 -0700 | [diff] [blame] | 369 | struct bpf_array *array = container_of(map, struct bpf_array, map); |
| 370 | struct cgroup *cgrp; |
Sargun Dhillon | 60d20f9 | 2016-08-12 08:56:52 -0700 | [diff] [blame] | 371 | |
| 372 | if (unlikely(in_interrupt())) |
| 373 | return -EINVAL; |
Sargun Dhillon | 60d20f9 | 2016-08-12 08:56:52 -0700 | [diff] [blame] | 374 | if (unlikely(idx >= array->map.max_entries)) |
| 375 | return -E2BIG; |
| 376 | |
| 377 | cgrp = READ_ONCE(array->ptrs[idx]); |
| 378 | if (unlikely(!cgrp)) |
| 379 | return -EAGAIN; |
| 380 | |
| 381 | return task_under_cgroup_hierarchy(current, cgrp); |
| 382 | } |
| 383 | |
| 384 | static const struct bpf_func_proto bpf_current_task_under_cgroup_proto = { |
| 385 | .func = bpf_current_task_under_cgroup, |
| 386 | .gpl_only = false, |
| 387 | .ret_type = RET_INTEGER, |
| 388 | .arg1_type = ARG_CONST_MAP_PTR, |
| 389 | .arg2_type = ARG_ANYTHING, |
| 390 | }; |
| 391 | |
Gianluca Borello | a5e8c07 | 2017-01-18 17:55:49 +0000 | [diff] [blame] | 392 | BPF_CALL_3(bpf_probe_read_str, void *, dst, u32, size, |
| 393 | const void *, unsafe_ptr) |
| 394 | { |
| 395 | int ret; |
| 396 | |
| 397 | /* |
| 398 | * The strncpy_from_unsafe() call will likely not fill the entire |
| 399 | * buffer, but that's okay in this circumstance as we're probing |
| 400 | * arbitrary memory anyway similar to bpf_probe_read() and might |
| 401 | * as well probe the stack. Thus, memory is explicitly cleared |
| 402 | * only in error case, so that improper users ignoring return |
| 403 | * code altogether don't copy garbage; otherwise length of string |
| 404 | * is returned that can be used for bpf_perf_event_output() et al. |
| 405 | */ |
| 406 | ret = strncpy_from_unsafe(dst, unsafe_ptr, size); |
| 407 | if (unlikely(ret < 0)) |
| 408 | memset(dst, 0, size); |
| 409 | |
| 410 | return ret; |
| 411 | } |
| 412 | |
| 413 | static const struct bpf_func_proto bpf_probe_read_str_proto = { |
| 414 | .func = bpf_probe_read_str, |
| 415 | .gpl_only = true, |
| 416 | .ret_type = RET_INTEGER, |
| 417 | .arg1_type = ARG_PTR_TO_UNINIT_MEM, |
| 418 | .arg2_type = ARG_CONST_SIZE, |
| 419 | .arg3_type = ARG_ANYTHING, |
| 420 | }; |
| 421 | |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 422 | static const struct bpf_func_proto *tracing_func_proto(enum bpf_func_id func_id) |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 423 | { |
| 424 | switch (func_id) { |
| 425 | case BPF_FUNC_map_lookup_elem: |
| 426 | return &bpf_map_lookup_elem_proto; |
| 427 | case BPF_FUNC_map_update_elem: |
| 428 | return &bpf_map_update_elem_proto; |
| 429 | case BPF_FUNC_map_delete_elem: |
| 430 | return &bpf_map_delete_elem_proto; |
| 431 | case BPF_FUNC_probe_read: |
| 432 | return &bpf_probe_read_proto; |
Alexei Starovoitov | d9847d3 | 2015-03-25 12:49:21 -0700 | [diff] [blame] | 433 | case BPF_FUNC_ktime_get_ns: |
| 434 | return &bpf_ktime_get_ns_proto; |
Alexei Starovoitov | 04fd61ab | 2015-05-19 16:59:03 -0700 | [diff] [blame] | 435 | case BPF_FUNC_tail_call: |
| 436 | return &bpf_tail_call_proto; |
Alexei Starovoitov | ffeedaf | 2015-06-12 19:39:12 -0700 | [diff] [blame] | 437 | case BPF_FUNC_get_current_pid_tgid: |
| 438 | return &bpf_get_current_pid_tgid_proto; |
Alexei Starovoitov | 606274c | 2016-07-06 22:38:36 -0700 | [diff] [blame] | 439 | case BPF_FUNC_get_current_task: |
| 440 | return &bpf_get_current_task_proto; |
Alexei Starovoitov | ffeedaf | 2015-06-12 19:39:12 -0700 | [diff] [blame] | 441 | case BPF_FUNC_get_current_uid_gid: |
| 442 | return &bpf_get_current_uid_gid_proto; |
| 443 | case BPF_FUNC_get_current_comm: |
| 444 | return &bpf_get_current_comm_proto; |
Alexei Starovoitov | 9c959c8 | 2015-03-25 12:49:22 -0700 | [diff] [blame] | 445 | case BPF_FUNC_trace_printk: |
Alexei Starovoitov | 0756ea3 | 2015-06-12 19:39:13 -0700 | [diff] [blame] | 446 | return bpf_get_trace_printk_proto(); |
Alexei Starovoitov | ab1973d | 2015-06-12 19:39:14 -0700 | [diff] [blame] | 447 | case BPF_FUNC_get_smp_processor_id: |
| 448 | return &bpf_get_smp_processor_id_proto; |
Daniel Borkmann | 2d0e30c | 2016-10-21 12:46:33 +0200 | [diff] [blame] | 449 | case BPF_FUNC_get_numa_node_id: |
| 450 | return &bpf_get_numa_node_id_proto; |
Kaixu Xia | 35578d7 | 2015-08-06 07:02:35 +0000 | [diff] [blame] | 451 | case BPF_FUNC_perf_event_read: |
| 452 | return &bpf_perf_event_read_proto; |
Sargun Dhillon | 96ae522 | 2016-07-25 05:54:46 -0700 | [diff] [blame] | 453 | case BPF_FUNC_probe_write_user: |
| 454 | return bpf_get_probe_write_proto(); |
Sargun Dhillon | 60d20f9 | 2016-08-12 08:56:52 -0700 | [diff] [blame] | 455 | case BPF_FUNC_current_task_under_cgroup: |
| 456 | return &bpf_current_task_under_cgroup_proto; |
Alexei Starovoitov | 8937bd8 | 2016-08-11 18:17:18 -0700 | [diff] [blame] | 457 | case BPF_FUNC_get_prandom_u32: |
| 458 | return &bpf_get_prandom_u32_proto; |
Gianluca Borello | a5e8c07 | 2017-01-18 17:55:49 +0000 | [diff] [blame] | 459 | case BPF_FUNC_probe_read_str: |
| 460 | return &bpf_probe_read_str_proto; |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 461 | default: |
| 462 | return NULL; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | static const struct bpf_func_proto *kprobe_prog_func_proto(enum bpf_func_id func_id) |
| 467 | { |
| 468 | switch (func_id) { |
Alexei Starovoitov | a43eec3 | 2015-10-20 20:02:34 -0700 | [diff] [blame] | 469 | case BPF_FUNC_perf_event_output: |
| 470 | return &bpf_perf_event_output_proto; |
Alexei Starovoitov | d5a3b1f | 2016-02-17 19:58:58 -0800 | [diff] [blame] | 471 | case BPF_FUNC_get_stackid: |
| 472 | return &bpf_get_stackid_proto; |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 473 | default: |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 474 | return tracing_func_proto(func_id); |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 475 | } |
| 476 | } |
| 477 | |
| 478 | /* bpf+kprobe programs can access fields of 'struct pt_regs' */ |
Alexei Starovoitov | 19de99f | 2016-06-15 18:25:38 -0700 | [diff] [blame] | 479 | static bool kprobe_prog_is_valid_access(int off, int size, enum bpf_access_type type, |
| 480 | enum bpf_reg_type *reg_type) |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 481 | { |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 482 | if (off < 0 || off >= sizeof(struct pt_regs)) |
| 483 | return false; |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 484 | if (type != BPF_READ) |
| 485 | return false; |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 486 | if (off % size != 0) |
| 487 | return false; |
Daniel Borkmann | 2d071c6 | 2017-01-15 01:34:25 +0100 | [diff] [blame] | 488 | /* |
| 489 | * Assertion for 32 bit to make sure last 8 byte access |
| 490 | * (BPF_DW) to the last 4 byte member is disallowed. |
| 491 | */ |
| 492 | if (off + size > sizeof(struct pt_regs)) |
| 493 | return false; |
| 494 | |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 495 | return true; |
| 496 | } |
| 497 | |
Johannes Berg | be9370a | 2017-04-11 15:34:57 +0200 | [diff] [blame] | 498 | const struct bpf_verifier_ops kprobe_prog_ops = { |
Alexei Starovoitov | 2541517 | 2015-03-25 12:49:20 -0700 | [diff] [blame] | 499 | .get_func_proto = kprobe_prog_func_proto, |
| 500 | .is_valid_access = kprobe_prog_is_valid_access, |
| 501 | }; |
| 502 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 503 | BPF_CALL_5(bpf_perf_event_output_tp, void *, tp_buff, struct bpf_map *, map, |
| 504 | u64, flags, void *, data, u64, size) |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 505 | { |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 506 | struct pt_regs *regs = *(struct pt_regs **)tp_buff; |
| 507 | |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 508 | /* |
| 509 | * r1 points to perf tracepoint buffer where first 8 bytes are hidden |
| 510 | * from bpf program and contain a pointer to 'struct pt_regs'. Fetch it |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 511 | * from there and call the same bpf_perf_event_output() helper inline. |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 512 | */ |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 513 | return ____bpf_perf_event_output(regs, map, flags, data, size); |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | static const struct bpf_func_proto bpf_perf_event_output_proto_tp = { |
| 517 | .func = bpf_perf_event_output_tp, |
| 518 | .gpl_only = true, |
| 519 | .ret_type = RET_INTEGER, |
| 520 | .arg1_type = ARG_PTR_TO_CTX, |
| 521 | .arg2_type = ARG_CONST_MAP_PTR, |
| 522 | .arg3_type = ARG_ANYTHING, |
Alexei Starovoitov | 39f19ebb | 2017-01-09 10:19:50 -0800 | [diff] [blame] | 523 | .arg4_type = ARG_PTR_TO_MEM, |
| 524 | .arg5_type = ARG_CONST_SIZE, |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 525 | }; |
| 526 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 527 | BPF_CALL_3(bpf_get_stackid_tp, void *, tp_buff, struct bpf_map *, map, |
| 528 | u64, flags) |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 529 | { |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 530 | struct pt_regs *regs = *(struct pt_regs **)tp_buff; |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 531 | |
Daniel Borkmann | f3694e0 | 2016-09-09 02:45:31 +0200 | [diff] [blame] | 532 | /* |
| 533 | * Same comment as in bpf_perf_event_output_tp(), only that this time |
| 534 | * the other helper's function body cannot be inlined due to being |
| 535 | * external, thus we need to call raw helper function. |
| 536 | */ |
| 537 | return bpf_get_stackid((unsigned long) regs, (unsigned long) map, |
| 538 | flags, 0, 0); |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | static const struct bpf_func_proto bpf_get_stackid_proto_tp = { |
| 542 | .func = bpf_get_stackid_tp, |
| 543 | .gpl_only = true, |
| 544 | .ret_type = RET_INTEGER, |
| 545 | .arg1_type = ARG_PTR_TO_CTX, |
| 546 | .arg2_type = ARG_CONST_MAP_PTR, |
| 547 | .arg3_type = ARG_ANYTHING, |
| 548 | }; |
| 549 | |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 550 | static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id) |
| 551 | { |
| 552 | switch (func_id) { |
| 553 | case BPF_FUNC_perf_event_output: |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 554 | return &bpf_perf_event_output_proto_tp; |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 555 | case BPF_FUNC_get_stackid: |
Alexei Starovoitov | 9940d67 | 2016-04-06 18:43:27 -0700 | [diff] [blame] | 556 | return &bpf_get_stackid_proto_tp; |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 557 | default: |
| 558 | return tracing_func_proto(func_id); |
| 559 | } |
| 560 | } |
| 561 | |
Alexei Starovoitov | 19de99f | 2016-06-15 18:25:38 -0700 | [diff] [blame] | 562 | static bool tp_prog_is_valid_access(int off, int size, enum bpf_access_type type, |
| 563 | enum bpf_reg_type *reg_type) |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 564 | { |
| 565 | if (off < sizeof(void *) || off >= PERF_MAX_TRACE_SIZE) |
| 566 | return false; |
| 567 | if (type != BPF_READ) |
| 568 | return false; |
| 569 | if (off % size != 0) |
| 570 | return false; |
Daniel Borkmann | 2d071c6 | 2017-01-15 01:34:25 +0100 | [diff] [blame] | 571 | |
| 572 | BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(__u64)); |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 573 | return true; |
| 574 | } |
| 575 | |
Johannes Berg | be9370a | 2017-04-11 15:34:57 +0200 | [diff] [blame] | 576 | const struct bpf_verifier_ops tracepoint_prog_ops = { |
Alexei Starovoitov | 9fd82b61 | 2016-04-06 18:43:26 -0700 | [diff] [blame] | 577 | .get_func_proto = tp_prog_func_proto, |
| 578 | .is_valid_access = tp_prog_is_valid_access, |
| 579 | }; |
| 580 | |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 581 | static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type, |
| 582 | enum bpf_reg_type *reg_type) |
| 583 | { |
| 584 | if (off < 0 || off >= sizeof(struct bpf_perf_event_data)) |
| 585 | return false; |
| 586 | if (type != BPF_READ) |
| 587 | return false; |
| 588 | if (off % size != 0) |
| 589 | return false; |
| 590 | if (off == offsetof(struct bpf_perf_event_data, sample_period)) { |
| 591 | if (size != sizeof(u64)) |
| 592 | return false; |
| 593 | } else { |
| 594 | if (size != sizeof(long)) |
| 595 | return false; |
| 596 | } |
| 597 | return true; |
| 598 | } |
| 599 | |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 600 | static u32 pe_prog_convert_ctx_access(enum bpf_access_type type, |
| 601 | const struct bpf_insn *si, |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 602 | struct bpf_insn *insn_buf, |
| 603 | struct bpf_prog *prog) |
| 604 | { |
| 605 | struct bpf_insn *insn = insn_buf; |
| 606 | |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 607 | switch (si->off) { |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 608 | case offsetof(struct bpf_perf_event_data, sample_period): |
| 609 | BUILD_BUG_ON(FIELD_SIZEOF(struct perf_sample_data, period) != sizeof(u64)); |
Daniel Borkmann | f035a51 | 2016-09-09 02:45:29 +0200 | [diff] [blame] | 610 | |
| 611 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_perf_event_data_kern, |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 612 | data), si->dst_reg, si->src_reg, |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 613 | offsetof(struct bpf_perf_event_data_kern, data)); |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 614 | *insn++ = BPF_LDX_MEM(BPF_DW, si->dst_reg, si->dst_reg, |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 615 | offsetof(struct perf_sample_data, period)); |
| 616 | break; |
| 617 | default: |
Daniel Borkmann | f035a51 | 2016-09-09 02:45:29 +0200 | [diff] [blame] | 618 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_perf_event_data_kern, |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 619 | regs), si->dst_reg, si->src_reg, |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 620 | offsetof(struct bpf_perf_event_data_kern, regs)); |
Daniel Borkmann | 6b8cc1d | 2017-01-12 11:51:32 +0100 | [diff] [blame] | 621 | *insn++ = BPF_LDX_MEM(BPF_SIZEOF(long), si->dst_reg, si->dst_reg, |
| 622 | si->off); |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 623 | break; |
| 624 | } |
| 625 | |
| 626 | return insn - insn_buf; |
| 627 | } |
| 628 | |
Johannes Berg | be9370a | 2017-04-11 15:34:57 +0200 | [diff] [blame] | 629 | const struct bpf_verifier_ops perf_event_prog_ops = { |
Alexei Starovoitov | 0515e59 | 2016-09-01 18:37:22 -0700 | [diff] [blame] | 630 | .get_func_proto = tp_prog_func_proto, |
| 631 | .is_valid_access = pe_prog_is_valid_access, |
| 632 | .convert_ctx_access = pe_prog_convert_ctx_access, |
| 633 | }; |