blob: 6fcf8dd148d06b868d1ab1212b420f2e73833848 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Kernel Probes (KProbes)
3 * kernel/kprobes.c
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * Copyright (C) IBM Corporation, 2002, 2004
20 *
21 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
22 * Probes initial implementation (includes suggestions from
23 * Rusty Russell).
24 * 2004-Aug Updated by Prasanna S Panchamukhi <prasanna@in.ibm.com> with
25 * hlists and exceptions notifier as suggested by Andi Kleen.
26 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
27 * interface to access function arguments.
28 * 2004-Sep Prasanna S Panchamukhi <prasanna@in.ibm.com> Changed Kprobes
29 * exceptions notifier to be first on the priority list.
Hien Nguyenb94cce92005-06-23 00:09:19 -070030 * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston
31 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
32 * <prasanna@in.ibm.com> added function-return probes.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 */
34#include <linux/kprobes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/hash.h>
36#include <linux/init.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080037#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <linux/module.h>
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070039#include <linux/moduleloader.h>
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -070040#include <linux/kallsyms.h>
Masami Hiramatsub4c6c342006-12-06 20:38:11 -080041#include <linux/freezer.h>
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -070042#include <asm-generic/sections.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <asm/cacheflush.h>
44#include <asm/errno.h>
45#include <asm/kdebug.h>
46
47#define KPROBE_HASH_BITS 6
48#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
49
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -070050
51/*
52 * Some oddball architectures like 64bit powerpc have function descriptors
53 * so this must be overridable.
54 */
55#ifndef kprobe_lookup_name
56#define kprobe_lookup_name(name, addr) \
57 addr = ((kprobe_opcode_t *)(kallsyms_lookup_name(name)))
58#endif
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
Hien Nguyenb94cce92005-06-23 00:09:19 -070061static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -070062static atomic_t kprobe_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -080064DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -080065DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -080066static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -070068static struct notifier_block kprobe_page_fault_nb = {
69 .notifier_call = kprobe_exceptions_notify,
70 .priority = 0x7fffffff /* we need to notified first */
71};
72
Anil S Keshavamurthy2d14e392006-01-09 20:52:41 -080073#ifdef __ARCH_WANT_KPROBES_INSN_SLOT
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070074/*
75 * kprobe->ainsn.insn points to the copy of the instruction to be
76 * single-stepped. x86_64, POWER4 and above have no-exec support and
77 * stepping on the instruction on a vmalloced/kmalloced/data page
78 * is a recipe for disaster
79 */
80#define INSNS_PER_PAGE (PAGE_SIZE/(MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
81
82struct kprobe_insn_page {
83 struct hlist_node hlist;
84 kprobe_opcode_t *insns; /* Page of instruction slots */
85 char slot_used[INSNS_PER_PAGE];
86 int nused;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -080087 int ngarbage;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070088};
89
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -080090enum kprobe_slot_state {
91 SLOT_CLEAN = 0,
92 SLOT_DIRTY = 1,
93 SLOT_USED = 2,
94};
95
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070096static struct hlist_head kprobe_insn_pages;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -080097static int kprobe_garbage_slots;
98static int collect_garbage_slots(void);
99
100static int __kprobes check_safety(void)
101{
102 int ret = 0;
103#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
104 ret = freeze_processes();
105 if (ret == 0) {
106 struct task_struct *p, *q;
107 do_each_thread(p, q) {
108 if (p != current && p->state == TASK_RUNNING &&
109 p->pid != 0) {
110 printk("Check failed: %s is running\n",p->comm);
111 ret = -1;
112 goto loop_end;
113 }
114 } while_each_thread(p, q);
115 }
116loop_end:
117 thaw_processes();
118#else
119 synchronize_sched();
120#endif
121 return ret;
122}
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700123
124/**
125 * get_insn_slot() - Find a slot on an executable page for an instruction.
126 * We allocate an executable page if there's no room on existing ones.
127 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700128kprobe_opcode_t __kprobes *get_insn_slot(void)
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700129{
130 struct kprobe_insn_page *kip;
131 struct hlist_node *pos;
132
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800133 retry:
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700134 hlist_for_each(pos, &kprobe_insn_pages) {
135 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
136 if (kip->nused < INSNS_PER_PAGE) {
137 int i;
138 for (i = 0; i < INSNS_PER_PAGE; i++) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800139 if (kip->slot_used[i] == SLOT_CLEAN) {
140 kip->slot_used[i] = SLOT_USED;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700141 kip->nused++;
142 return kip->insns + (i * MAX_INSN_SIZE);
143 }
144 }
145 /* Surprise! No unused slots. Fix kip->nused. */
146 kip->nused = INSNS_PER_PAGE;
147 }
148 }
149
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800150 /* If there are any garbage slots, collect it and try again. */
151 if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
152 goto retry;
153 }
154 /* All out of space. Need to allocate a new page. Use slot 0. */
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700155 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
156 if (!kip) {
157 return NULL;
158 }
159
160 /*
161 * Use module_alloc so this page is within +/- 2GB of where the
162 * kernel image and loaded module images reside. This is required
163 * so x86_64 can correctly handle the %rip-relative fixups.
164 */
165 kip->insns = module_alloc(PAGE_SIZE);
166 if (!kip->insns) {
167 kfree(kip);
168 return NULL;
169 }
170 INIT_HLIST_NODE(&kip->hlist);
171 hlist_add_head(&kip->hlist, &kprobe_insn_pages);
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800172 memset(kip->slot_used, SLOT_CLEAN, INSNS_PER_PAGE);
173 kip->slot_used[0] = SLOT_USED;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700174 kip->nused = 1;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800175 kip->ngarbage = 0;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700176 return kip->insns;
177}
178
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800179/* Return 1 if all garbages are collected, otherwise 0. */
180static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
181{
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800182 kip->slot_used[idx] = SLOT_CLEAN;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800183 kip->nused--;
184 if (kip->nused == 0) {
185 /*
186 * Page is no longer in use. Free it unless
187 * it's the last one. We keep the last one
188 * so as not to have to set it up again the
189 * next time somebody inserts a probe.
190 */
191 hlist_del(&kip->hlist);
192 if (hlist_empty(&kprobe_insn_pages)) {
193 INIT_HLIST_NODE(&kip->hlist);
194 hlist_add_head(&kip->hlist,
195 &kprobe_insn_pages);
196 } else {
197 module_free(NULL, kip->insns);
198 kfree(kip);
199 }
200 return 1;
201 }
202 return 0;
203}
204
205static int __kprobes collect_garbage_slots(void)
206{
207 struct kprobe_insn_page *kip;
208 struct hlist_node *pos, *next;
209
210 /* Ensure no-one is preepmted on the garbages */
211 if (check_safety() != 0)
212 return -EAGAIN;
213
214 hlist_for_each_safe(pos, next, &kprobe_insn_pages) {
215 int i;
216 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
217 if (kip->ngarbage == 0)
218 continue;
219 kip->ngarbage = 0; /* we will collect all garbages */
220 for (i = 0; i < INSNS_PER_PAGE; i++) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800221 if (kip->slot_used[i] == SLOT_DIRTY &&
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800222 collect_one_slot(kip, i))
223 break;
224 }
225 }
226 kprobe_garbage_slots = 0;
227 return 0;
228}
229
230void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700231{
232 struct kprobe_insn_page *kip;
233 struct hlist_node *pos;
234
235 hlist_for_each(pos, &kprobe_insn_pages) {
236 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
237 if (kip->insns <= slot &&
238 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
239 int i = (slot - kip->insns) / MAX_INSN_SIZE;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800240 if (dirty) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800241 kip->slot_used[i] = SLOT_DIRTY;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800242 kip->ngarbage++;
243 } else {
244 collect_one_slot(kip, i);
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700245 }
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800246 break;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700247 }
248 }
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800249 if (dirty && (++kprobe_garbage_slots > INSNS_PER_PAGE)) {
250 collect_garbage_slots();
251 }
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700252}
Anil S Keshavamurthy2d14e392006-01-09 20:52:41 -0800253#endif
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700254
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800255/* We have preemption disabled.. so it is safe to use __ versions */
256static inline void set_kprobe_instance(struct kprobe *kp)
257{
258 __get_cpu_var(kprobe_instance) = kp;
259}
260
261static inline void reset_kprobe_instance(void)
262{
263 __get_cpu_var(kprobe_instance) = NULL;
264}
265
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800266/*
267 * This routine is called either:
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800268 * - under the kprobe_mutex - during kprobe_[un]register()
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800269 * OR
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800270 * - with preemption disabled - from arch/xxx/kernel/kprobes.c
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800271 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700272struct kprobe __kprobes *get_kprobe(void *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273{
274 struct hlist_head *head;
275 struct hlist_node *node;
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800276 struct kprobe *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
278 head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800279 hlist_for_each_entry_rcu(p, node, head, hlist) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 if (p->addr == addr)
281 return p;
282 }
283 return NULL;
284}
285
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700286/*
287 * Aggregate handlers for multiple kprobes support - these handlers
288 * take care of invoking the individual kprobe handlers on p->list
289 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700290static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700291{
292 struct kprobe *kp;
293
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800294 list_for_each_entry_rcu(kp, &p->list, list) {
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700295 if (kp->pre_handler) {
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800296 set_kprobe_instance(kp);
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700297 if (kp->pre_handler(kp, regs))
298 return 1;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700299 }
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800300 reset_kprobe_instance();
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700301 }
302 return 0;
303}
304
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700305static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
306 unsigned long flags)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700307{
308 struct kprobe *kp;
309
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800310 list_for_each_entry_rcu(kp, &p->list, list) {
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700311 if (kp->post_handler) {
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800312 set_kprobe_instance(kp);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700313 kp->post_handler(kp, regs, flags);
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800314 reset_kprobe_instance();
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700315 }
316 }
317 return;
318}
319
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700320static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
321 int trapnr)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700322{
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800323 struct kprobe *cur = __get_cpu_var(kprobe_instance);
324
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700325 /*
326 * if we faulted "during" the execution of a user specified
327 * probe handler, invoke just that probe's fault handler
328 */
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800329 if (cur && cur->fault_handler) {
330 if (cur->fault_handler(cur, regs, trapnr))
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700331 return 1;
332 }
333 return 0;
334}
335
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700336static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700337{
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800338 struct kprobe *cur = __get_cpu_var(kprobe_instance);
339 int ret = 0;
340
341 if (cur && cur->break_handler) {
342 if (cur->break_handler(cur, regs))
343 ret = 1;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700344 }
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800345 reset_kprobe_instance();
346 return ret;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700347}
348
Keshavamurthy Anil Sbf8d5c52005-12-12 00:37:34 -0800349/* Walks the list and increments nmissed count for multiprobe case */
350void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
351{
352 struct kprobe *kp;
353 if (p->pre_handler != aggr_pre_handler) {
354 p->nmissed++;
355 } else {
356 list_for_each_entry_rcu(kp, &p->list, list)
357 kp->nmissed++;
358 }
359 return;
360}
361
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800362/* Called with kretprobe_lock held */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700363struct kretprobe_instance __kprobes *get_free_rp_inst(struct kretprobe *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700364{
365 struct hlist_node *node;
366 struct kretprobe_instance *ri;
367 hlist_for_each_entry(ri, node, &rp->free_instances, uflist)
368 return ri;
369 return NULL;
370}
371
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800372/* Called with kretprobe_lock held */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700373static struct kretprobe_instance __kprobes *get_used_rp_inst(struct kretprobe
374 *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700375{
376 struct hlist_node *node;
377 struct kretprobe_instance *ri;
378 hlist_for_each_entry(ri, node, &rp->used_instances, uflist)
379 return ri;
380 return NULL;
381}
382
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800383/* Called with kretprobe_lock held */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700384void __kprobes add_rp_inst(struct kretprobe_instance *ri)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700385{
Hien Nguyenb94cce92005-06-23 00:09:19 -0700386 /*
387 * Remove rp inst off the free list -
388 * Add it back when probed function returns
389 */
390 hlist_del(&ri->uflist);
Rusty Lynch802eae72005-06-27 15:17:08 -0700391
Hien Nguyenb94cce92005-06-23 00:09:19 -0700392 /* Add rp inst onto table */
393 INIT_HLIST_NODE(&ri->hlist);
394 hlist_add_head(&ri->hlist,
Rusty Lynch802eae72005-06-27 15:17:08 -0700395 &kretprobe_inst_table[hash_ptr(ri->task, KPROBE_HASH_BITS)]);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700396
397 /* Also add this rp inst to the used list. */
398 INIT_HLIST_NODE(&ri->uflist);
399 hlist_add_head(&ri->uflist, &ri->rp->used_instances);
400}
401
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800402/* Called with kretprobe_lock held */
bibo,mao99219a32006-10-02 02:17:35 -0700403void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
404 struct hlist_head *head)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700405{
406 /* remove rp inst off the rprobe_inst_table */
407 hlist_del(&ri->hlist);
408 if (ri->rp) {
409 /* remove rp inst off the used list */
410 hlist_del(&ri->uflist);
411 /* put rp inst back onto the free list */
412 INIT_HLIST_NODE(&ri->uflist);
413 hlist_add_head(&ri->uflist, &ri->rp->free_instances);
414 } else
415 /* Unregistering */
bibo,mao99219a32006-10-02 02:17:35 -0700416 hlist_add_head(&ri->hlist, head);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700417}
418
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700419struct hlist_head __kprobes *kretprobe_inst_table_head(struct task_struct *tsk)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700420{
421 return &kretprobe_inst_table[hash_ptr(tsk, KPROBE_HASH_BITS)];
422}
423
Hien Nguyenb94cce92005-06-23 00:09:19 -0700424/*
bibo maoc6fd91f2006-03-26 01:38:20 -0800425 * This function is called from finish_task_switch when task tk becomes dead,
426 * so that we can recycle any function-return probe instances associated
427 * with this task. These left over instances represent probed functions
428 * that have been called but will never return.
Hien Nguyenb94cce92005-06-23 00:09:19 -0700429 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700430void __kprobes kprobe_flush_task(struct task_struct *tk)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700431{
bibo,mao62c27be2006-10-02 02:17:33 -0700432 struct kretprobe_instance *ri;
bibo,mao99219a32006-10-02 02:17:35 -0700433 struct hlist_head *head, empty_rp;
Rusty Lynch802eae72005-06-27 15:17:08 -0700434 struct hlist_node *node, *tmp;
Hien Nguyen0aa55e42005-06-23 00:09:26 -0700435 unsigned long flags = 0;
Rusty Lynch802eae72005-06-27 15:17:08 -0700436
bibo,mao99219a32006-10-02 02:17:35 -0700437 INIT_HLIST_HEAD(&empty_rp);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800438 spin_lock_irqsave(&kretprobe_lock, flags);
bibo,mao62c27be2006-10-02 02:17:33 -0700439 head = kretprobe_inst_table_head(tk);
440 hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
441 if (ri->task == tk)
bibo,mao99219a32006-10-02 02:17:35 -0700442 recycle_rp_inst(ri, &empty_rp);
bibo,mao62c27be2006-10-02 02:17:33 -0700443 }
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800444 spin_unlock_irqrestore(&kretprobe_lock, flags);
bibo,mao99219a32006-10-02 02:17:35 -0700445
446 hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
447 hlist_del(&ri->hlist);
448 kfree(ri);
449 }
Hien Nguyenb94cce92005-06-23 00:09:19 -0700450}
451
Hien Nguyenb94cce92005-06-23 00:09:19 -0700452static inline void free_rp_inst(struct kretprobe *rp)
453{
454 struct kretprobe_instance *ri;
455 while ((ri = get_free_rp_inst(rp)) != NULL) {
456 hlist_del(&ri->uflist);
457 kfree(ri);
458 }
459}
460
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700461/*
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700462 * Keep all fields in the kprobe consistent
463 */
464static inline void copy_kprobe(struct kprobe *old_p, struct kprobe *p)
465{
466 memcpy(&p->opcode, &old_p->opcode, sizeof(kprobe_opcode_t));
467 memcpy(&p->ainsn, &old_p->ainsn, sizeof(struct arch_specific_insn));
468}
469
470/*
471* Add the new probe to old_p->list. Fail if this is the
472* second jprobe at the address - two jprobes can't coexist
473*/
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700474static int __kprobes add_new_kprobe(struct kprobe *old_p, struct kprobe *p)
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700475{
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700476 if (p->break_handler) {
mao, bibo36721652006-06-26 00:25:22 -0700477 if (old_p->break_handler)
478 return -EEXIST;
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800479 list_add_tail_rcu(&p->list, &old_p->list);
mao, bibo36721652006-06-26 00:25:22 -0700480 old_p->break_handler = aggr_break_handler;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700481 } else
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800482 list_add_rcu(&p->list, &old_p->list);
mao, bibo36721652006-06-26 00:25:22 -0700483 if (p->post_handler && !old_p->post_handler)
484 old_p->post_handler = aggr_post_handler;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700485 return 0;
486}
487
488/*
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700489 * Fill in the required fields of the "manager kprobe". Replace the
490 * earlier kprobe in the hlist with the manager kprobe
491 */
492static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
493{
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700494 copy_kprobe(p, ap);
bibo, maoa9ad9652006-07-30 03:03:26 -0700495 flush_insn_slot(ap);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700496 ap->addr = p->addr;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700497 ap->pre_handler = aggr_pre_handler;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700498 ap->fault_handler = aggr_fault_handler;
mao, bibo36721652006-06-26 00:25:22 -0700499 if (p->post_handler)
500 ap->post_handler = aggr_post_handler;
501 if (p->break_handler)
502 ap->break_handler = aggr_break_handler;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700503
504 INIT_LIST_HEAD(&ap->list);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800505 list_add_rcu(&p->list, &ap->list);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700506
Keshavamurthy Anil Sadad0f32005-12-12 00:37:12 -0800507 hlist_replace_rcu(&p->hlist, &ap->hlist);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700508}
509
510/*
511 * This is the second or subsequent kprobe at the address - handle
512 * the intricacies
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700513 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700514static int __kprobes register_aggr_kprobe(struct kprobe *old_p,
515 struct kprobe *p)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700516{
517 int ret = 0;
518 struct kprobe *ap;
519
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700520 if (old_p->pre_handler == aggr_pre_handler) {
521 copy_kprobe(old_p, p);
522 ret = add_new_kprobe(old_p, p);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700523 } else {
Keshavamurthy Anil Sa0d50062006-01-09 20:52:46 -0800524 ap = kzalloc(sizeof(struct kprobe), GFP_KERNEL);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700525 if (!ap)
526 return -ENOMEM;
527 add_aggr_kprobe(ap, old_p);
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700528 copy_kprobe(ap, p);
529 ret = add_new_kprobe(ap, p);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700530 }
531 return ret;
532}
533
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700534static int __kprobes in_kprobes_functions(unsigned long addr)
535{
536 if (addr >= (unsigned long)__kprobes_text_start
537 && addr < (unsigned long)__kprobes_text_end)
538 return -EINVAL;
539 return 0;
540}
541
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800542static int __kprobes __register_kprobe(struct kprobe *p,
543 unsigned long called_from)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544{
545 int ret = 0;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700546 struct kprobe *old_p;
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800547 struct module *probed_mod;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -0700549 /*
550 * If we have a symbol_name argument look it up,
551 * and add it to the address. That way the addr
552 * field can either be global or relative to a symbol.
553 */
554 if (p->symbol_name) {
555 if (p->addr)
556 return -EINVAL;
557 kprobe_lookup_name(p->symbol_name, p->addr);
558 }
559
560 if (!p->addr)
561 return -EINVAL;
562 p->addr = (kprobe_opcode_t *)(((char *)p->addr)+ p->offset);
563
Mao, Bibob3e55c72005-12-12 00:37:00 -0800564 if ((!kernel_text_address((unsigned long) p->addr)) ||
565 in_kprobes_functions((unsigned long) p->addr))
566 return -EINVAL;
567
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800568 p->mod_refcounted = 0;
569 /* Check are we probing a module */
570 if ((probed_mod = module_text_address((unsigned long) p->addr))) {
571 struct module *calling_mod = module_text_address(called_from);
572 /* We must allow modules to probe themself and
573 * in this case avoid incrementing the module refcount,
574 * so as to allow unloading of self probing modules.
575 */
576 if (calling_mod && (calling_mod != probed_mod)) {
577 if (unlikely(!try_module_get(probed_mod)))
578 return -EINVAL;
579 p->mod_refcounted = 1;
580 } else
581 probed_mod = NULL;
582 }
Mao, Bibob3e55c72005-12-12 00:37:00 -0800583
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800584 p->nmissed = 0;
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800585 mutex_lock(&kprobe_mutex);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700586 old_p = get_kprobe(p->addr);
587 if (old_p) {
588 ret = register_aggr_kprobe(old_p, p);
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -0700589 if (!ret)
590 atomic_inc(&kprobe_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 goto out;
592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800594 if ((ret = arch_prepare_kprobe(p)) != 0)
595 goto out;
596
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700597 INIT_HLIST_NODE(&p->hlist);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800598 hlist_add_head_rcu(&p->hlist,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
600
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -0700601 if (atomic_add_return(1, &kprobe_count) == \
602 (ARCH_INACTIVE_KPROBE_COUNT + 1))
603 register_page_fault_notifier(&kprobe_page_fault_nb);
604
bibo,mao62c27be2006-10-02 02:17:33 -0700605 arch_arm_kprobe(p);
Rusty Lynch7e1048b2005-06-23 00:09:25 -0700606
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607out:
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800608 mutex_unlock(&kprobe_mutex);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800609
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800610 if (ret && probed_mod)
611 module_put(probed_mod);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 return ret;
613}
614
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800615int __kprobes register_kprobe(struct kprobe *p)
616{
617 return __register_kprobe(p,
618 (unsigned long)__builtin_return_address(0));
619}
620
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700621void __kprobes unregister_kprobe(struct kprobe *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622{
Mao, Bibob3e55c72005-12-12 00:37:00 -0800623 struct module *mod;
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800624 struct kprobe *old_p, *list_p;
625 int cleanup_p;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700626
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800627 mutex_lock(&kprobe_mutex);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700628 old_p = get_kprobe(p->addr);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800629 if (unlikely(!old_p)) {
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800630 mutex_unlock(&kprobe_mutex);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800631 return;
632 }
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800633 if (p != old_p) {
634 list_for_each_entry_rcu(list_p, &old_p->list, list)
635 if (list_p == p)
636 /* kprobe p is a valid probe */
637 goto valid_p;
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800638 mutex_unlock(&kprobe_mutex);
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800639 return;
640 }
641valid_p:
642 if ((old_p == p) || ((old_p->pre_handler == aggr_pre_handler) &&
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800643 (p->list.next == &old_p->list) &&
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800644 (p->list.prev == &old_p->list))) {
645 /* Only probe on the hash list */
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800646 arch_disarm_kprobe(p);
647 hlist_del_rcu(&old_p->hlist);
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800648 cleanup_p = 1;
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800649 } else {
650 list_del_rcu(&p->list);
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800651 cleanup_p = 0;
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800652 }
Mao, Bibob3e55c72005-12-12 00:37:00 -0800653
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800654 mutex_unlock(&kprobe_mutex);
Mao, Bibob3e55c72005-12-12 00:37:00 -0800655
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800656 synchronize_sched();
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800657 if (p->mod_refcounted &&
658 (mod = module_text_address((unsigned long)p->addr)))
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800659 module_put(mod);
660
661 if (cleanup_p) {
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800662 if (p != old_p) {
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800663 list_del_rcu(&p->list);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800664 kfree(old_p);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800665 }
Ananth N Mavinakayanahalli0498b632006-01-09 20:52:46 -0800666 arch_remove_kprobe(p);
mao, bibo36721652006-06-26 00:25:22 -0700667 } else {
668 mutex_lock(&kprobe_mutex);
669 if (p->break_handler)
670 old_p->break_handler = NULL;
671 if (p->post_handler){
672 list_for_each_entry_rcu(list_p, &old_p->list, list){
673 if (list_p->post_handler){
674 cleanup_p = 2;
675 break;
676 }
677 }
678 if (cleanup_p == 0)
679 old_p->post_handler = NULL;
680 }
681 mutex_unlock(&kprobe_mutex);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800682 }
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -0700683
684 /* Call unregister_page_fault_notifier()
685 * if no probes are active
686 */
687 mutex_lock(&kprobe_mutex);
688 if (atomic_add_return(-1, &kprobe_count) == \
689 ARCH_INACTIVE_KPROBE_COUNT)
690 unregister_page_fault_notifier(&kprobe_page_fault_nb);
691 mutex_unlock(&kprobe_mutex);
692 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693}
694
695static struct notifier_block kprobe_exceptions_nb = {
696 .notifier_call = kprobe_exceptions_notify,
Anil S Keshavamurthy3d5631e2006-06-26 00:25:28 -0700697 .priority = 0x7fffffff /* we need to be notified first */
698};
699
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700701int __kprobes register_jprobe(struct jprobe *jp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702{
703 /* Todo: Verify probepoint is a function entry point */
704 jp->kp.pre_handler = setjmp_pre_handler;
705 jp->kp.break_handler = longjmp_break_handler;
706
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800707 return __register_kprobe(&jp->kp,
708 (unsigned long)__builtin_return_address(0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709}
710
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700711void __kprobes unregister_jprobe(struct jprobe *jp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712{
713 unregister_kprobe(&jp->kp);
714}
715
Hien Nguyenb94cce92005-06-23 00:09:19 -0700716#ifdef ARCH_SUPPORTS_KRETPROBES
717
Adrian Bunke65cefe2006-02-03 03:03:42 -0800718/*
719 * This kprobe pre_handler is registered with every kretprobe. When probe
720 * hits it will set up the return probe.
721 */
722static int __kprobes pre_handler_kretprobe(struct kprobe *p,
723 struct pt_regs *regs)
724{
725 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
726 unsigned long flags = 0;
727
728 /*TODO: consider to only swap the RA after the last pre_handler fired */
729 spin_lock_irqsave(&kretprobe_lock, flags);
730 arch_prepare_kretprobe(rp, regs);
731 spin_unlock_irqrestore(&kretprobe_lock, flags);
732 return 0;
733}
734
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700735int __kprobes register_kretprobe(struct kretprobe *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700736{
737 int ret = 0;
738 struct kretprobe_instance *inst;
739 int i;
740
741 rp->kp.pre_handler = pre_handler_kretprobe;
Ananth N Mavinakayanahalli7522a842006-04-20 02:43:11 -0700742 rp->kp.post_handler = NULL;
743 rp->kp.fault_handler = NULL;
744 rp->kp.break_handler = NULL;
Hien Nguyenb94cce92005-06-23 00:09:19 -0700745
746 /* Pre-allocate memory for max kretprobe instances */
747 if (rp->maxactive <= 0) {
748#ifdef CONFIG_PREEMPT
749 rp->maxactive = max(10, 2 * NR_CPUS);
750#else
751 rp->maxactive = NR_CPUS;
752#endif
753 }
754 INIT_HLIST_HEAD(&rp->used_instances);
755 INIT_HLIST_HEAD(&rp->free_instances);
756 for (i = 0; i < rp->maxactive; i++) {
757 inst = kmalloc(sizeof(struct kretprobe_instance), GFP_KERNEL);
758 if (inst == NULL) {
759 free_rp_inst(rp);
760 return -ENOMEM;
761 }
762 INIT_HLIST_NODE(&inst->uflist);
763 hlist_add_head(&inst->uflist, &rp->free_instances);
764 }
765
766 rp->nmissed = 0;
767 /* Establish function entry probe point */
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800768 if ((ret = __register_kprobe(&rp->kp,
769 (unsigned long)__builtin_return_address(0))) != 0)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700770 free_rp_inst(rp);
771 return ret;
772}
773
774#else /* ARCH_SUPPORTS_KRETPROBES */
775
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700776int __kprobes register_kretprobe(struct kretprobe *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700777{
778 return -ENOSYS;
779}
780
781#endif /* ARCH_SUPPORTS_KRETPROBES */
782
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700783void __kprobes unregister_kretprobe(struct kretprobe *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700784{
785 unsigned long flags;
786 struct kretprobe_instance *ri;
787
788 unregister_kprobe(&rp->kp);
789 /* No race here */
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800790 spin_lock_irqsave(&kretprobe_lock, flags);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700791 while ((ri = get_used_rp_inst(rp)) != NULL) {
792 ri->rp = NULL;
793 hlist_del(&ri->uflist);
794 }
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800795 spin_unlock_irqrestore(&kretprobe_lock, flags);
Ananth N Mavinakayanahalli278ff952006-02-03 03:03:43 -0800796 free_rp_inst(rp);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700797}
798
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799static int __init init_kprobes(void)
800{
801 int i, err = 0;
802
803 /* FIXME allocate the probe table, currently defined statically */
804 /* initialize all list heads */
Hien Nguyenb94cce92005-06-23 00:09:19 -0700805 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 INIT_HLIST_HEAD(&kprobe_table[i]);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700807 INIT_HLIST_HEAD(&kretprobe_inst_table[i]);
808 }
Anil S Keshavamurthye6f47f92006-06-26 00:25:29 -0700809 atomic_set(&kprobe_count, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810
Rusty Lynch67729262005-07-05 18:54:50 -0700811 err = arch_init_kprobes();
Rusty Lynch802eae72005-06-27 15:17:08 -0700812 if (!err)
813 err = register_die_notifier(&kprobe_exceptions_nb);
814
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 return err;
816}
817
818__initcall(init_kprobes);
819
820EXPORT_SYMBOL_GPL(register_kprobe);
821EXPORT_SYMBOL_GPL(unregister_kprobe);
822EXPORT_SYMBOL_GPL(register_jprobe);
823EXPORT_SYMBOL_GPL(unregister_jprobe);
824EXPORT_SYMBOL_GPL(jprobe_return);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700825EXPORT_SYMBOL_GPL(register_kretprobe);
826EXPORT_SYMBOL_GPL(unregister_kretprobe);
827