Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
| 2 | /* Copyright (c) 2019 Facebook */ |
| 3 | #include <linux/hash.h> |
| 4 | #include <linux/bpf.h> |
| 5 | #include <linux/filter.h> |
Alexei Starovoitov | b91e014 | 2019-12-08 16:01:13 -0800 | [diff] [blame] | 6 | #include <linux/ftrace.h> |
Jiri Olsa | e9b4e60 | 2020-01-23 17:15:07 +0100 | [diff] [blame] | 7 | #include <linux/rbtree_latch.h> |
Jiri Olsa | a108f7d | 2020-03-12 20:56:05 +0100 | [diff] [blame] | 8 | #include <linux/perf_event.h> |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 9 | #include <linux/btf.h> |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 10 | #include <linux/rcupdate_trace.h> |
| 11 | #include <linux/rcupdate_wait.h> |
Jiri Olsa | 861de02 | 2021-03-26 11:59:00 +0100 | [diff] [blame] | 12 | #include <linux/module.h> |
Song Liu | 856c02d | 2021-09-10 11:33:51 -0700 | [diff] [blame] | 13 | #include <linux/static_call.h> |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 14 | |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 15 | /* dummy _ops. The verifier will operate on target program's ops. */ |
| 16 | const struct bpf_verifier_ops bpf_extension_verifier_ops = { |
| 17 | }; |
| 18 | const struct bpf_prog_ops bpf_extension_prog_ops = { |
| 19 | }; |
| 20 | |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 21 | /* btf_vmlinux has ~22k attachable functions. 1k htab is enough. */ |
| 22 | #define TRAMPOLINE_HASH_BITS 10 |
| 23 | #define TRAMPOLINE_TABLE_SIZE (1 << TRAMPOLINE_HASH_BITS) |
| 24 | |
| 25 | static struct hlist_head trampoline_table[TRAMPOLINE_TABLE_SIZE]; |
| 26 | |
Jiri Olsa | 7ac88eb | 2020-03-12 20:56:07 +0100 | [diff] [blame] | 27 | /* serializes access to trampoline_table */ |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 28 | static DEFINE_MUTEX(trampoline_mutex); |
| 29 | |
Jiri Olsa | 7ac88eb | 2020-03-12 20:56:07 +0100 | [diff] [blame] | 30 | void *bpf_jit_alloc_exec_page(void) |
Björn Töpel | 98e8627 | 2019-12-13 18:51:07 +0100 | [diff] [blame] | 31 | { |
| 32 | void *image; |
| 33 | |
| 34 | image = bpf_jit_alloc_exec(PAGE_SIZE); |
| 35 | if (!image) |
| 36 | return NULL; |
| 37 | |
| 38 | set_vm_flush_reset_perms(image); |
| 39 | /* Keep image as writeable. The alternative is to keep flipping ro/rw |
| 40 | * everytime new program is attached or detached. |
| 41 | */ |
| 42 | set_memory_x((long)image, 1); |
| 43 | return image; |
| 44 | } |
| 45 | |
Jiri Olsa | a108f7d | 2020-03-12 20:56:05 +0100 | [diff] [blame] | 46 | void bpf_image_ksym_add(void *data, struct bpf_ksym *ksym) |
| 47 | { |
| 48 | ksym->start = (unsigned long) data; |
Jiri Olsa | 7ac88eb | 2020-03-12 20:56:07 +0100 | [diff] [blame] | 49 | ksym->end = ksym->start + PAGE_SIZE; |
Jiri Olsa | a108f7d | 2020-03-12 20:56:05 +0100 | [diff] [blame] | 50 | bpf_ksym_add(ksym); |
| 51 | perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF, ksym->start, |
Jiri Olsa | 7ac88eb | 2020-03-12 20:56:07 +0100 | [diff] [blame] | 52 | PAGE_SIZE, false, ksym->name); |
Jiri Olsa | a108f7d | 2020-03-12 20:56:05 +0100 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void bpf_image_ksym_del(struct bpf_ksym *ksym) |
| 56 | { |
| 57 | bpf_ksym_del(ksym); |
| 58 | perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF, ksym->start, |
Jiri Olsa | 7ac88eb | 2020-03-12 20:56:07 +0100 | [diff] [blame] | 59 | PAGE_SIZE, true, ksym->name); |
Jiri Olsa | a108f7d | 2020-03-12 20:56:05 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Toke Høiland-Jørgensen | f7b12b6 | 2020-09-25 23:25:02 +0200 | [diff] [blame] | 62 | static struct bpf_trampoline *bpf_trampoline_lookup(u64 key) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 63 | { |
| 64 | struct bpf_trampoline *tr; |
| 65 | struct hlist_head *head; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 66 | int i; |
| 67 | |
| 68 | mutex_lock(&trampoline_mutex); |
| 69 | head = &trampoline_table[hash_64(key, TRAMPOLINE_HASH_BITS)]; |
| 70 | hlist_for_each_entry(tr, head, hlist) { |
| 71 | if (tr->key == key) { |
| 72 | refcount_inc(&tr->refcnt); |
| 73 | goto out; |
| 74 | } |
| 75 | } |
| 76 | tr = kzalloc(sizeof(*tr), GFP_KERNEL); |
| 77 | if (!tr) |
| 78 | goto out; |
| 79 | |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 80 | tr->key = key; |
| 81 | INIT_HLIST_NODE(&tr->hlist); |
| 82 | hlist_add_head(&tr->hlist, head); |
| 83 | refcount_set(&tr->refcnt, 1); |
| 84 | mutex_init(&tr->mutex); |
| 85 | for (i = 0; i < BPF_TRAMP_MAX; i++) |
| 86 | INIT_HLIST_HEAD(&tr->progs_hlist[i]); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 87 | out: |
| 88 | mutex_unlock(&trampoline_mutex); |
| 89 | return tr; |
| 90 | } |
| 91 | |
Jiri Olsa | 861de02 | 2021-03-26 11:59:00 +0100 | [diff] [blame] | 92 | static int bpf_trampoline_module_get(struct bpf_trampoline *tr) |
| 93 | { |
| 94 | struct module *mod; |
| 95 | int err = 0; |
| 96 | |
| 97 | preempt_disable(); |
| 98 | mod = __module_text_address((unsigned long) tr->func.addr); |
| 99 | if (mod && !try_module_get(mod)) |
| 100 | err = -ENOENT; |
| 101 | preempt_enable(); |
| 102 | tr->mod = mod; |
| 103 | return err; |
| 104 | } |
| 105 | |
| 106 | static void bpf_trampoline_module_put(struct bpf_trampoline *tr) |
| 107 | { |
| 108 | module_put(tr->mod); |
| 109 | tr->mod = NULL; |
| 110 | } |
| 111 | |
Alexei Starovoitov | b91e014 | 2019-12-08 16:01:13 -0800 | [diff] [blame] | 112 | static int is_ftrace_location(void *ip) |
| 113 | { |
| 114 | long addr; |
| 115 | |
| 116 | addr = ftrace_location((long)ip); |
| 117 | if (!addr) |
| 118 | return 0; |
| 119 | if (WARN_ON_ONCE(addr != (long)ip)) |
| 120 | return -EFAULT; |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | static int unregister_fentry(struct bpf_trampoline *tr, void *old_addr) |
| 125 | { |
| 126 | void *ip = tr->func.addr; |
| 127 | int ret; |
| 128 | |
| 129 | if (tr->func.ftrace_managed) |
| 130 | ret = unregister_ftrace_direct((long)ip, (long)old_addr); |
| 131 | else |
| 132 | ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, old_addr, NULL); |
Jiri Olsa | 861de02 | 2021-03-26 11:59:00 +0100 | [diff] [blame] | 133 | |
| 134 | if (!ret) |
| 135 | bpf_trampoline_module_put(tr); |
Alexei Starovoitov | b91e014 | 2019-12-08 16:01:13 -0800 | [diff] [blame] | 136 | return ret; |
| 137 | } |
| 138 | |
| 139 | static int modify_fentry(struct bpf_trampoline *tr, void *old_addr, void *new_addr) |
| 140 | { |
| 141 | void *ip = tr->func.addr; |
| 142 | int ret; |
| 143 | |
| 144 | if (tr->func.ftrace_managed) |
| 145 | ret = modify_ftrace_direct((long)ip, (long)old_addr, (long)new_addr); |
| 146 | else |
| 147 | ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, old_addr, new_addr); |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | /* first time registering */ |
| 152 | static int register_fentry(struct bpf_trampoline *tr, void *new_addr) |
| 153 | { |
| 154 | void *ip = tr->func.addr; |
| 155 | int ret; |
| 156 | |
| 157 | ret = is_ftrace_location(ip); |
| 158 | if (ret < 0) |
| 159 | return ret; |
| 160 | tr->func.ftrace_managed = ret; |
| 161 | |
Jiri Olsa | 861de02 | 2021-03-26 11:59:00 +0100 | [diff] [blame] | 162 | if (bpf_trampoline_module_get(tr)) |
| 163 | return -ENOENT; |
| 164 | |
Alexei Starovoitov | b91e014 | 2019-12-08 16:01:13 -0800 | [diff] [blame] | 165 | if (tr->func.ftrace_managed) |
| 166 | ret = register_ftrace_direct((long)ip, (long)new_addr); |
| 167 | else |
| 168 | ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, NULL, new_addr); |
Jiri Olsa | 861de02 | 2021-03-26 11:59:00 +0100 | [diff] [blame] | 169 | |
| 170 | if (ret) |
| 171 | bpf_trampoline_module_put(tr); |
Alexei Starovoitov | b91e014 | 2019-12-08 16:01:13 -0800 | [diff] [blame] | 172 | return ret; |
| 173 | } |
| 174 | |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 175 | static struct bpf_tramp_progs * |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 176 | bpf_trampoline_get_progs(const struct bpf_trampoline *tr, int *total, bool *ip_arg) |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 177 | { |
| 178 | const struct bpf_prog_aux *aux; |
| 179 | struct bpf_tramp_progs *tprogs; |
| 180 | struct bpf_prog **progs; |
| 181 | int kind; |
| 182 | |
| 183 | *total = 0; |
| 184 | tprogs = kcalloc(BPF_TRAMP_MAX, sizeof(*tprogs), GFP_KERNEL); |
| 185 | if (!tprogs) |
| 186 | return ERR_PTR(-ENOMEM); |
| 187 | |
| 188 | for (kind = 0; kind < BPF_TRAMP_MAX; kind++) { |
| 189 | tprogs[kind].nr_progs = tr->progs_cnt[kind]; |
| 190 | *total += tr->progs_cnt[kind]; |
| 191 | progs = tprogs[kind].progs; |
| 192 | |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 193 | hlist_for_each_entry(aux, &tr->progs_hlist[kind], tramp_hlist) { |
| 194 | *ip_arg |= aux->prog->call_get_func_ip; |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 195 | *progs++ = aux->prog; |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 196 | } |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 197 | } |
| 198 | return tprogs; |
| 199 | } |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 200 | |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 201 | static void __bpf_tramp_image_put_deferred(struct work_struct *work) |
| 202 | { |
| 203 | struct bpf_tramp_image *im; |
| 204 | |
| 205 | im = container_of(work, struct bpf_tramp_image, work); |
| 206 | bpf_image_ksym_del(&im->ksym); |
| 207 | bpf_jit_free_exec(im->image); |
| 208 | bpf_jit_uncharge_modmem(1); |
| 209 | percpu_ref_exit(&im->pcref); |
| 210 | kfree_rcu(im, rcu); |
| 211 | } |
| 212 | |
| 213 | /* callback, fexit step 3 or fentry step 2 */ |
| 214 | static void __bpf_tramp_image_put_rcu(struct rcu_head *rcu) |
| 215 | { |
| 216 | struct bpf_tramp_image *im; |
| 217 | |
| 218 | im = container_of(rcu, struct bpf_tramp_image, rcu); |
| 219 | INIT_WORK(&im->work, __bpf_tramp_image_put_deferred); |
| 220 | schedule_work(&im->work); |
| 221 | } |
| 222 | |
| 223 | /* callback, fexit step 2. Called after percpu_ref_kill confirms. */ |
| 224 | static void __bpf_tramp_image_release(struct percpu_ref *pcref) |
| 225 | { |
| 226 | struct bpf_tramp_image *im; |
| 227 | |
| 228 | im = container_of(pcref, struct bpf_tramp_image, pcref); |
| 229 | call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu); |
| 230 | } |
| 231 | |
| 232 | /* callback, fexit or fentry step 1 */ |
| 233 | static void __bpf_tramp_image_put_rcu_tasks(struct rcu_head *rcu) |
| 234 | { |
| 235 | struct bpf_tramp_image *im; |
| 236 | |
| 237 | im = container_of(rcu, struct bpf_tramp_image, rcu); |
| 238 | if (im->ip_after_call) |
| 239 | /* the case of fmod_ret/fexit trampoline and CONFIG_PREEMPTION=y */ |
| 240 | percpu_ref_kill(&im->pcref); |
| 241 | else |
| 242 | /* the case of fentry trampoline */ |
| 243 | call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu); |
| 244 | } |
| 245 | |
| 246 | static void bpf_tramp_image_put(struct bpf_tramp_image *im) |
| 247 | { |
| 248 | /* The trampoline image that calls original function is using: |
| 249 | * rcu_read_lock_trace to protect sleepable bpf progs |
| 250 | * rcu_read_lock to protect normal bpf progs |
| 251 | * percpu_ref to protect trampoline itself |
| 252 | * rcu tasks to protect trampoline asm not covered by percpu_ref |
| 253 | * (which are few asm insns before __bpf_tramp_enter and |
| 254 | * after __bpf_tramp_exit) |
| 255 | * |
| 256 | * The trampoline is unreachable before bpf_tramp_image_put(). |
| 257 | * |
| 258 | * First, patch the trampoline to avoid calling into fexit progs. |
| 259 | * The progs will be freed even if the original function is still |
| 260 | * executing or sleeping. |
| 261 | * In case of CONFIG_PREEMPT=y use call_rcu_tasks() to wait on |
| 262 | * first few asm instructions to execute and call into |
| 263 | * __bpf_tramp_enter->percpu_ref_get. |
| 264 | * Then use percpu_ref_kill to wait for the trampoline and the original |
| 265 | * function to finish. |
| 266 | * Then use call_rcu_tasks() to make sure few asm insns in |
| 267 | * the trampoline epilogue are done as well. |
| 268 | * |
| 269 | * In !PREEMPT case the task that got interrupted in the first asm |
| 270 | * insns won't go through an RCU quiescent state which the |
| 271 | * percpu_ref_kill will be waiting for. Hence the first |
| 272 | * call_rcu_tasks() is not necessary. |
| 273 | */ |
| 274 | if (im->ip_after_call) { |
| 275 | int err = bpf_arch_text_poke(im->ip_after_call, BPF_MOD_JUMP, |
| 276 | NULL, im->ip_epilogue); |
| 277 | WARN_ON(err); |
| 278 | if (IS_ENABLED(CONFIG_PREEMPTION)) |
| 279 | call_rcu_tasks(&im->rcu, __bpf_tramp_image_put_rcu_tasks); |
| 280 | else |
| 281 | percpu_ref_kill(&im->pcref); |
| 282 | return; |
| 283 | } |
| 284 | |
| 285 | /* The trampoline without fexit and fmod_ret progs doesn't call original |
| 286 | * function and doesn't use percpu_ref. |
| 287 | * Use call_rcu_tasks_trace() to wait for sleepable progs to finish. |
| 288 | * Then use call_rcu_tasks() to wait for the rest of trampoline asm |
| 289 | * and normal progs. |
| 290 | */ |
| 291 | call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks); |
| 292 | } |
| 293 | |
| 294 | static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, u32 idx) |
| 295 | { |
| 296 | struct bpf_tramp_image *im; |
| 297 | struct bpf_ksym *ksym; |
| 298 | void *image; |
| 299 | int err = -ENOMEM; |
| 300 | |
| 301 | im = kzalloc(sizeof(*im), GFP_KERNEL); |
| 302 | if (!im) |
| 303 | goto out; |
| 304 | |
| 305 | err = bpf_jit_charge_modmem(1); |
| 306 | if (err) |
| 307 | goto out_free_im; |
| 308 | |
| 309 | err = -ENOMEM; |
| 310 | im->image = image = bpf_jit_alloc_exec_page(); |
| 311 | if (!image) |
| 312 | goto out_uncharge; |
| 313 | |
| 314 | err = percpu_ref_init(&im->pcref, __bpf_tramp_image_release, 0, GFP_KERNEL); |
| 315 | if (err) |
| 316 | goto out_free_image; |
| 317 | |
| 318 | ksym = &im->ksym; |
| 319 | INIT_LIST_HEAD_RCU(&ksym->lnode); |
| 320 | snprintf(ksym->name, KSYM_NAME_LEN, "bpf_trampoline_%llu_%u", key, idx); |
| 321 | bpf_image_ksym_add(image, ksym); |
| 322 | return im; |
| 323 | |
| 324 | out_free_image: |
| 325 | bpf_jit_free_exec(im->image); |
| 326 | out_uncharge: |
| 327 | bpf_jit_uncharge_modmem(1); |
| 328 | out_free_im: |
| 329 | kfree(im); |
| 330 | out: |
| 331 | return ERR_PTR(err); |
| 332 | } |
| 333 | |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 334 | static int bpf_trampoline_update(struct bpf_trampoline *tr) |
| 335 | { |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 336 | struct bpf_tramp_image *im; |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 337 | struct bpf_tramp_progs *tprogs; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 338 | u32 flags = BPF_TRAMP_F_RESTORE_REGS; |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 339 | bool ip_arg = false; |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 340 | int err, total; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 341 | |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 342 | tprogs = bpf_trampoline_get_progs(tr, &total, &ip_arg); |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 343 | if (IS_ERR(tprogs)) |
| 344 | return PTR_ERR(tprogs); |
| 345 | |
| 346 | if (total == 0) { |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 347 | err = unregister_fentry(tr, tr->cur_image->image); |
| 348 | bpf_tramp_image_put(tr->cur_image); |
| 349 | tr->cur_image = NULL; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 350 | tr->selector = 0; |
| 351 | goto out; |
| 352 | } |
| 353 | |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 354 | im = bpf_tramp_image_alloc(tr->key, tr->selector); |
| 355 | if (IS_ERR(im)) { |
| 356 | err = PTR_ERR(im); |
| 357 | goto out; |
| 358 | } |
| 359 | |
KP Singh | ae24082 | 2020-03-04 20:18:49 +0100 | [diff] [blame] | 360 | if (tprogs[BPF_TRAMP_FEXIT].nr_progs || |
| 361 | tprogs[BPF_TRAMP_MODIFY_RETURN].nr_progs) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 362 | flags = BPF_TRAMP_F_CALL_ORIG | BPF_TRAMP_F_SKIP_FRAME; |
| 363 | |
Jiri Olsa | 1e37392 | 2021-07-14 11:43:54 +0200 | [diff] [blame] | 364 | if (ip_arg) |
| 365 | flags |= BPF_TRAMP_F_IP_ARG; |
| 366 | |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 367 | err = arch_prepare_bpf_trampoline(im, im->image, im->image + PAGE_SIZE, |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 368 | &tr->func.model, flags, tprogs, |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 369 | tr->func.addr); |
Martin KaFai Lau | 85d33df | 2020-01-08 16:35:05 -0800 | [diff] [blame] | 370 | if (err < 0) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 371 | goto out; |
| 372 | |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 373 | WARN_ON(tr->cur_image && tr->selector == 0); |
| 374 | WARN_ON(!tr->cur_image && tr->selector); |
| 375 | if (tr->cur_image) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 376 | /* progs already running at this address */ |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 377 | err = modify_fentry(tr, tr->cur_image->image, im->image); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 378 | else |
| 379 | /* first time registering */ |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 380 | err = register_fentry(tr, im->image); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 381 | if (err) |
| 382 | goto out; |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 383 | if (tr->cur_image) |
| 384 | bpf_tramp_image_put(tr->cur_image); |
| 385 | tr->cur_image = im; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 386 | tr->selector++; |
| 387 | out: |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 388 | kfree(tprogs); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 389 | return err; |
| 390 | } |
| 391 | |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 392 | static enum bpf_tramp_prog_type bpf_attach_type_to_tramp(struct bpf_prog *prog) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 393 | { |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 394 | switch (prog->expected_attach_type) { |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 395 | case BPF_TRACE_FENTRY: |
| 396 | return BPF_TRAMP_FENTRY; |
KP Singh | ae24082 | 2020-03-04 20:18:49 +0100 | [diff] [blame] | 397 | case BPF_MODIFY_RETURN: |
| 398 | return BPF_TRAMP_MODIFY_RETURN; |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 399 | case BPF_TRACE_FEXIT: |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 400 | return BPF_TRAMP_FEXIT; |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 401 | case BPF_LSM_MAC: |
| 402 | if (!prog->aux->attach_func_proto->type) |
| 403 | /* The function returns void, we cannot modify its |
| 404 | * return value. |
| 405 | */ |
| 406 | return BPF_TRAMP_FEXIT; |
| 407 | else |
| 408 | return BPF_TRAMP_MODIFY_RETURN; |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 409 | default: |
| 410 | return BPF_TRAMP_REPLACE; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 411 | } |
| 412 | } |
| 413 | |
Toke Høiland-Jørgensen | 3aac1ea | 2020-09-29 14:45:50 +0200 | [diff] [blame] | 414 | int bpf_trampoline_link_prog(struct bpf_prog *prog, struct bpf_trampoline *tr) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 415 | { |
| 416 | enum bpf_tramp_prog_type kind; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 417 | int err = 0; |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 418 | int cnt; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 419 | |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 420 | kind = bpf_attach_type_to_tramp(prog); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 421 | mutex_lock(&tr->mutex); |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 422 | if (tr->extension_prog) { |
| 423 | /* cannot attach fentry/fexit if extension prog is attached. |
| 424 | * cannot overwrite extension prog either. |
| 425 | */ |
| 426 | err = -EBUSY; |
| 427 | goto out; |
| 428 | } |
| 429 | cnt = tr->progs_cnt[BPF_TRAMP_FENTRY] + tr->progs_cnt[BPF_TRAMP_FEXIT]; |
| 430 | if (kind == BPF_TRAMP_REPLACE) { |
| 431 | /* Cannot attach extension if fentry/fexit are in use. */ |
| 432 | if (cnt) { |
| 433 | err = -EBUSY; |
| 434 | goto out; |
| 435 | } |
| 436 | tr->extension_prog = prog; |
| 437 | err = bpf_arch_text_poke(tr->func.addr, BPF_MOD_JUMP, NULL, |
| 438 | prog->bpf_func); |
| 439 | goto out; |
| 440 | } |
| 441 | if (cnt >= BPF_MAX_TRAMP_PROGS) { |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 442 | err = -E2BIG; |
| 443 | goto out; |
| 444 | } |
| 445 | if (!hlist_unhashed(&prog->aux->tramp_hlist)) { |
| 446 | /* prog already linked */ |
| 447 | err = -EBUSY; |
| 448 | goto out; |
| 449 | } |
| 450 | hlist_add_head(&prog->aux->tramp_hlist, &tr->progs_hlist[kind]); |
| 451 | tr->progs_cnt[kind]++; |
Toke Høiland-Jørgensen | 3aac1ea | 2020-09-29 14:45:50 +0200 | [diff] [blame] | 452 | err = bpf_trampoline_update(tr); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 453 | if (err) { |
Jiri Olsa | f3a9507 | 2021-04-14 21:51:41 +0200 | [diff] [blame] | 454 | hlist_del_init(&prog->aux->tramp_hlist); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 455 | tr->progs_cnt[kind]--; |
| 456 | } |
| 457 | out: |
| 458 | mutex_unlock(&tr->mutex); |
| 459 | return err; |
| 460 | } |
| 461 | |
| 462 | /* bpf_trampoline_unlink_prog() should never fail. */ |
Toke Høiland-Jørgensen | 3aac1ea | 2020-09-29 14:45:50 +0200 | [diff] [blame] | 463 | int bpf_trampoline_unlink_prog(struct bpf_prog *prog, struct bpf_trampoline *tr) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 464 | { |
| 465 | enum bpf_tramp_prog_type kind; |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 466 | int err; |
| 467 | |
KP Singh | 9e4e01d | 2020-03-29 01:43:52 +0100 | [diff] [blame] | 468 | kind = bpf_attach_type_to_tramp(prog); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 469 | mutex_lock(&tr->mutex); |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 470 | if (kind == BPF_TRAMP_REPLACE) { |
| 471 | WARN_ON_ONCE(!tr->extension_prog); |
| 472 | err = bpf_arch_text_poke(tr->func.addr, BPF_MOD_JUMP, |
| 473 | tr->extension_prog->bpf_func, NULL); |
| 474 | tr->extension_prog = NULL; |
| 475 | goto out; |
| 476 | } |
Jiri Olsa | f3a9507 | 2021-04-14 21:51:41 +0200 | [diff] [blame] | 477 | hlist_del_init(&prog->aux->tramp_hlist); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 478 | tr->progs_cnt[kind]--; |
Toke Høiland-Jørgensen | 3aac1ea | 2020-09-29 14:45:50 +0200 | [diff] [blame] | 479 | err = bpf_trampoline_update(tr); |
Alexei Starovoitov | be8704f | 2020-01-20 16:53:46 -0800 | [diff] [blame] | 480 | out: |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 481 | mutex_unlock(&tr->mutex); |
| 482 | return err; |
| 483 | } |
| 484 | |
Toke Høiland-Jørgensen | f7b12b6 | 2020-09-25 23:25:02 +0200 | [diff] [blame] | 485 | struct bpf_trampoline *bpf_trampoline_get(u64 key, |
| 486 | struct bpf_attach_target_info *tgt_info) |
| 487 | { |
| 488 | struct bpf_trampoline *tr; |
| 489 | |
| 490 | tr = bpf_trampoline_lookup(key); |
| 491 | if (!tr) |
| 492 | return NULL; |
| 493 | |
| 494 | mutex_lock(&tr->mutex); |
| 495 | if (tr->func.addr) |
| 496 | goto out; |
| 497 | |
| 498 | memcpy(&tr->func.model, &tgt_info->fmodel, sizeof(tgt_info->fmodel)); |
| 499 | tr->func.addr = (void *)tgt_info->tgt_addr; |
| 500 | out: |
| 501 | mutex_unlock(&tr->mutex); |
| 502 | return tr; |
| 503 | } |
| 504 | |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 505 | void bpf_trampoline_put(struct bpf_trampoline *tr) |
| 506 | { |
| 507 | if (!tr) |
| 508 | return; |
| 509 | mutex_lock(&trampoline_mutex); |
| 510 | if (!refcount_dec_and_test(&tr->refcnt)) |
| 511 | goto out; |
| 512 | WARN_ON_ONCE(mutex_is_locked(&tr->mutex)); |
| 513 | if (WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[BPF_TRAMP_FENTRY]))) |
| 514 | goto out; |
| 515 | if (WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[BPF_TRAMP_FEXIT]))) |
| 516 | goto out; |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 517 | /* This code will be executed even when the last bpf_tramp_image |
| 518 | * is alive. All progs are detached from the trampoline and the |
| 519 | * trampoline image is patched with jmp into epilogue to skip |
| 520 | * fexit progs. The fentry-only trampoline will be freed via |
| 521 | * multiple rcu callbacks. |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 522 | */ |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 523 | hlist_del(&tr->hlist); |
| 524 | kfree(tr); |
| 525 | out: |
| 526 | mutex_unlock(&trampoline_mutex); |
| 527 | } |
| 528 | |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 529 | #define NO_START_TIME 1 |
Song Liu | 856c02d | 2021-09-10 11:33:51 -0700 | [diff] [blame] | 530 | static __always_inline u64 notrace bpf_prog_start_time(void) |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 531 | { |
| 532 | u64 start = NO_START_TIME; |
| 533 | |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 534 | if (static_branch_unlikely(&bpf_stats_enabled_key)) { |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 535 | start = sched_clock(); |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 536 | if (unlikely(!start)) |
| 537 | start = NO_START_TIME; |
| 538 | } |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 539 | return start; |
| 540 | } |
| 541 | |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 542 | static void notrace inc_misses_counter(struct bpf_prog *prog) |
| 543 | { |
| 544 | struct bpf_prog_stats *stats; |
| 545 | |
| 546 | stats = this_cpu_ptr(prog->stats); |
| 547 | u64_stats_update_begin(&stats->syncp); |
Eric Dumazet | 61a0aba | 2021-10-26 14:41:33 -0700 | [diff] [blame^] | 548 | u64_stats_inc(&stats->misses); |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 549 | u64_stats_update_end(&stats->syncp); |
| 550 | } |
| 551 | |
Andrii Nakryiko | fb7dd8b | 2021-08-15 00:05:54 -0700 | [diff] [blame] | 552 | /* The logic is similar to bpf_prog_run(), but with an explicit |
David Miller | 02ad059 | 2020-02-24 15:01:45 +0100 | [diff] [blame] | 553 | * rcu_read_lock() and migrate_disable() which are required |
| 554 | * for the trampoline. The macro is split into |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 555 | * call __bpf_prog_enter |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 556 | * call prog->bpf_func |
| 557 | * call __bpf_prog_exit |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 558 | * |
| 559 | * __bpf_prog_enter returns: |
| 560 | * 0 - skip execution of the bpf prog |
| 561 | * 1 - execute bpf prog |
Zhen Lei | 8fb33b6 | 2021-05-25 10:56:59 +0800 | [diff] [blame] | 562 | * [2..MAX_U64] - execute bpf prog and record execution time. |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 563 | * This is start time. |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 564 | */ |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 565 | u64 notrace __bpf_prog_enter(struct bpf_prog *prog) |
Jules Irenge | dcce11d | 2020-03-11 01:09:01 +0000 | [diff] [blame] | 566 | __acquires(RCU) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 567 | { |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 568 | rcu_read_lock(); |
David Miller | 02ad059 | 2020-02-24 15:01:45 +0100 | [diff] [blame] | 569 | migrate_disable(); |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 570 | if (unlikely(__this_cpu_inc_return(*(prog->active)) != 1)) { |
| 571 | inc_misses_counter(prog); |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 572 | return 0; |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 573 | } |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 574 | return bpf_prog_start_time(); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 575 | } |
| 576 | |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 577 | static void notrace update_prog_stats(struct bpf_prog *prog, |
| 578 | u64 start) |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 579 | { |
| 580 | struct bpf_prog_stats *stats; |
| 581 | |
| 582 | if (static_branch_unlikely(&bpf_stats_enabled_key) && |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 583 | /* static_key could be enabled in __bpf_prog_enter* |
| 584 | * and disabled in __bpf_prog_exit*. |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 585 | * And vice versa. |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 586 | * Hence check that 'start' is valid. |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 587 | */ |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 588 | start > NO_START_TIME) { |
Eric Dumazet | d979617 | 2021-10-26 14:41:32 -0700 | [diff] [blame] | 589 | unsigned long flags; |
| 590 | |
Alexei Starovoitov | 700d479 | 2021-02-09 19:36:26 -0800 | [diff] [blame] | 591 | stats = this_cpu_ptr(prog->stats); |
Eric Dumazet | d979617 | 2021-10-26 14:41:32 -0700 | [diff] [blame] | 592 | flags = u64_stats_update_begin_irqsave(&stats->syncp); |
Eric Dumazet | 61a0aba | 2021-10-26 14:41:33 -0700 | [diff] [blame^] | 593 | u64_stats_inc(&stats->cnt); |
| 594 | u64_stats_add(&stats->nsecs, sched_clock() - start); |
Eric Dumazet | d979617 | 2021-10-26 14:41:32 -0700 | [diff] [blame] | 595 | u64_stats_update_end_irqrestore(&stats->syncp, flags); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 596 | } |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start) |
| 600 | __releases(RCU) |
| 601 | { |
| 602 | update_prog_stats(prog, start); |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 603 | __this_cpu_dec(*(prog->active)); |
David Miller | 02ad059 | 2020-02-24 15:01:45 +0100 | [diff] [blame] | 604 | migrate_enable(); |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 605 | rcu_read_unlock(); |
| 606 | } |
| 607 | |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 608 | u64 notrace __bpf_prog_enter_sleepable(struct bpf_prog *prog) |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 609 | { |
| 610 | rcu_read_lock_trace(); |
Alexei Starovoitov | 031d6e0 | 2021-02-09 19:36:27 -0800 | [diff] [blame] | 611 | migrate_disable(); |
Alexei Starovoitov | f56407f | 2020-08-31 13:16:51 -0700 | [diff] [blame] | 612 | might_fault(); |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 613 | if (unlikely(__this_cpu_inc_return(*(prog->active)) != 1)) { |
| 614 | inc_misses_counter(prog); |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 615 | return 0; |
Alexei Starovoitov | 9ed9e9b | 2021-02-09 19:36:31 -0800 | [diff] [blame] | 616 | } |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 617 | return bpf_prog_start_time(); |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 618 | } |
| 619 | |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 620 | void notrace __bpf_prog_exit_sleepable(struct bpf_prog *prog, u64 start) |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 621 | { |
Alexei Starovoitov | f2dd3b3 | 2021-02-09 19:36:28 -0800 | [diff] [blame] | 622 | update_prog_stats(prog, start); |
Alexei Starovoitov | ca06f55 | 2021-02-09 19:36:29 -0800 | [diff] [blame] | 623 | __this_cpu_dec(*(prog->active)); |
Alexei Starovoitov | 031d6e0 | 2021-02-09 19:36:27 -0800 | [diff] [blame] | 624 | migrate_enable(); |
Alexei Starovoitov | 1e6c62a | 2020-08-27 15:01:11 -0700 | [diff] [blame] | 625 | rcu_read_unlock_trace(); |
| 626 | } |
| 627 | |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 628 | void notrace __bpf_tramp_enter(struct bpf_tramp_image *tr) |
| 629 | { |
| 630 | percpu_ref_get(&tr->pcref); |
| 631 | } |
| 632 | |
| 633 | void notrace __bpf_tramp_exit(struct bpf_tramp_image *tr) |
| 634 | { |
| 635 | percpu_ref_put(&tr->pcref); |
| 636 | } |
| 637 | |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 638 | int __weak |
Alexei Starovoitov | e21aa34 | 2021-03-16 14:00:07 -0700 | [diff] [blame] | 639 | arch_prepare_bpf_trampoline(struct bpf_tramp_image *tr, void *image, void *image_end, |
Martin KaFai Lau | 85d33df | 2020-01-08 16:35:05 -0800 | [diff] [blame] | 640 | const struct btf_func_model *m, u32 flags, |
KP Singh | 88fd9e5 | 2020-03-04 20:18:47 +0100 | [diff] [blame] | 641 | struct bpf_tramp_progs *tprogs, |
Alexei Starovoitov | fec56f5 | 2019-11-14 10:57:04 -0800 | [diff] [blame] | 642 | void *orig_call) |
| 643 | { |
| 644 | return -ENOTSUPP; |
| 645 | } |
| 646 | |
| 647 | static int __init init_trampolines(void) |
| 648 | { |
| 649 | int i; |
| 650 | |
| 651 | for (i = 0; i < TRAMPOLINE_TABLE_SIZE; i++) |
| 652 | INIT_HLIST_HEAD(&trampoline_table[i]); |
| 653 | return 0; |
| 654 | } |
| 655 | late_initcall(init_trampolines); |