blob: 9f8a3f25259a9da4c8535bab07014b07da79a643 [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>
Randy Dunlape3869792007-05-08 00:27:01 -070038#include <linux/stddef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/module.h>
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070040#include <linux/moduleloader.h>
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -070041#include <linux/kallsyms.h>
Masami Hiramatsub4c6c342006-12-06 20:38:11 -080042#include <linux/freezer.h>
Srinivasa Ds346fd592007-02-20 13:57:54 -080043#include <linux/seq_file.h>
44#include <linux/debugfs.h>
Christoph Hellwig1eeb66a2007-05-08 00:27:03 -070045#include <linux/kdebug.h>
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -070046
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -070047#include <asm-generic/sections.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <asm/cacheflush.h>
49#include <asm/errno.h>
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -070050#include <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#define KPROBE_HASH_BITS 6
53#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
54
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -070055
56/*
57 * Some oddball architectures like 64bit powerpc have function descriptors
58 * so this must be overridable.
59 */
60#ifndef kprobe_lookup_name
61#define kprobe_lookup_name(name, addr) \
62 addr = ((kprobe_opcode_t *)(kallsyms_lookup_name(name)))
63#endif
64
Srinivasa D Sef53d9c2008-07-25 01:46:04 -070065static int kprobes_initialized;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
Hien Nguyenb94cce92005-06-23 00:09:19 -070067static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -070069/* NOTE: change this value only with kprobe_mutex held */
70static bool kprobe_enabled;
71
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -080072DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -080073static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;
Srinivasa D Sef53d9c2008-07-25 01:46:04 -070074static struct {
Andrew Morton7e036d02008-11-12 13:26:57 -080075 spinlock_t lock ____cacheline_aligned_in_smp;
Srinivasa D Sef53d9c2008-07-25 01:46:04 -070076} kretprobe_table_locks[KPROBE_TABLE_SIZE];
77
78static spinlock_t *kretprobe_table_lock_ptr(unsigned long hash)
79{
80 return &(kretprobe_table_locks[hash].lock);
81}
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
Srinivasa Ds3d8d9962008-04-28 02:14:26 -070083/*
84 * Normally, functions that we'd want to prohibit kprobes in, are marked
85 * __kprobes. But, there are cases where such functions already belong to
86 * a different section (__sched for preempt_schedule)
87 *
88 * For such cases, we now have a blacklist
89 */
Daniel Guilak544304b2008-07-10 09:38:19 -070090static struct kprobe_blackpoint kprobe_blacklist[] = {
Srinivasa Ds3d8d9962008-04-28 02:14:26 -070091 {"preempt_schedule",},
92 {NULL} /* Terminator */
93};
94
Anil S Keshavamurthy2d14e392006-01-09 20:52:41 -080095#ifdef __ARCH_WANT_KPROBES_INSN_SLOT
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -070096/*
97 * kprobe->ainsn.insn points to the copy of the instruction to be
98 * single-stepped. x86_64, POWER4 and above have no-exec support and
99 * stepping on the instruction on a vmalloced/kmalloced/data page
100 * is a recipe for disaster
101 */
102#define INSNS_PER_PAGE (PAGE_SIZE/(MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
103
104struct kprobe_insn_page {
105 struct hlist_node hlist;
106 kprobe_opcode_t *insns; /* Page of instruction slots */
107 char slot_used[INSNS_PER_PAGE];
108 int nused;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800109 int ngarbage;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700110};
111
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800112enum kprobe_slot_state {
113 SLOT_CLEAN = 0,
114 SLOT_DIRTY = 1,
115 SLOT_USED = 2,
116};
117
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700118static struct hlist_head kprobe_insn_pages;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800119static int kprobe_garbage_slots;
120static int collect_garbage_slots(void);
121
122static int __kprobes check_safety(void)
123{
124 int ret = 0;
125#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
126 ret = freeze_processes();
127 if (ret == 0) {
128 struct task_struct *p, *q;
129 do_each_thread(p, q) {
130 if (p != current && p->state == TASK_RUNNING &&
131 p->pid != 0) {
132 printk("Check failed: %s is running\n",p->comm);
133 ret = -1;
134 goto loop_end;
135 }
136 } while_each_thread(p, q);
137 }
138loop_end:
139 thaw_processes();
140#else
141 synchronize_sched();
142#endif
143 return ret;
144}
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700145
146/**
147 * get_insn_slot() - Find a slot on an executable page for an instruction.
148 * We allocate an executable page if there's no room on existing ones.
149 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700150kprobe_opcode_t __kprobes *get_insn_slot(void)
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700151{
152 struct kprobe_insn_page *kip;
153 struct hlist_node *pos;
154
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700155 retry:
Christoph Hellwigb0bb5012007-05-08 00:34:11 -0700156 hlist_for_each_entry(kip, pos, &kprobe_insn_pages, hlist) {
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700157 if (kip->nused < INSNS_PER_PAGE) {
158 int i;
159 for (i = 0; i < INSNS_PER_PAGE; i++) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800160 if (kip->slot_used[i] == SLOT_CLEAN) {
161 kip->slot_used[i] = SLOT_USED;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700162 kip->nused++;
163 return kip->insns + (i * MAX_INSN_SIZE);
164 }
165 }
166 /* Surprise! No unused slots. Fix kip->nused. */
167 kip->nused = INSNS_PER_PAGE;
168 }
169 }
170
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800171 /* If there are any garbage slots, collect it and try again. */
172 if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
173 goto retry;
174 }
175 /* All out of space. Need to allocate a new page. Use slot 0. */
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700176 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700177 if (!kip)
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700178 return NULL;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700179
180 /*
181 * Use module_alloc so this page is within +/- 2GB of where the
182 * kernel image and loaded module images reside. This is required
183 * so x86_64 can correctly handle the %rip-relative fixups.
184 */
185 kip->insns = module_alloc(PAGE_SIZE);
186 if (!kip->insns) {
187 kfree(kip);
188 return NULL;
189 }
190 INIT_HLIST_NODE(&kip->hlist);
191 hlist_add_head(&kip->hlist, &kprobe_insn_pages);
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800192 memset(kip->slot_used, SLOT_CLEAN, INSNS_PER_PAGE);
193 kip->slot_used[0] = SLOT_USED;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700194 kip->nused = 1;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800195 kip->ngarbage = 0;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700196 return kip->insns;
197}
198
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800199/* Return 1 if all garbages are collected, otherwise 0. */
200static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
201{
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800202 kip->slot_used[idx] = SLOT_CLEAN;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800203 kip->nused--;
204 if (kip->nused == 0) {
205 /*
206 * Page is no longer in use. Free it unless
207 * it's the last one. We keep the last one
208 * so as not to have to set it up again the
209 * next time somebody inserts a probe.
210 */
211 hlist_del(&kip->hlist);
212 if (hlist_empty(&kprobe_insn_pages)) {
213 INIT_HLIST_NODE(&kip->hlist);
214 hlist_add_head(&kip->hlist,
215 &kprobe_insn_pages);
216 } else {
217 module_free(NULL, kip->insns);
218 kfree(kip);
219 }
220 return 1;
221 }
222 return 0;
223}
224
225static int __kprobes collect_garbage_slots(void)
226{
227 struct kprobe_insn_page *kip;
228 struct hlist_node *pos, *next;
229
230 /* Ensure no-one is preepmted on the garbages */
231 if (check_safety() != 0)
232 return -EAGAIN;
233
Christoph Hellwigb0bb5012007-05-08 00:34:11 -0700234 hlist_for_each_entry_safe(kip, pos, next, &kprobe_insn_pages, hlist) {
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800235 int i;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800236 if (kip->ngarbage == 0)
237 continue;
238 kip->ngarbage = 0; /* we will collect all garbages */
239 for (i = 0; i < INSNS_PER_PAGE; i++) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800240 if (kip->slot_used[i] == SLOT_DIRTY &&
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800241 collect_one_slot(kip, i))
242 break;
243 }
244 }
245 kprobe_garbage_slots = 0;
246 return 0;
247}
248
249void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700250{
251 struct kprobe_insn_page *kip;
252 struct hlist_node *pos;
253
Christoph Hellwigb0bb5012007-05-08 00:34:11 -0700254 hlist_for_each_entry(kip, pos, &kprobe_insn_pages, hlist) {
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700255 if (kip->insns <= slot &&
256 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
257 int i = (slot - kip->insns) / MAX_INSN_SIZE;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800258 if (dirty) {
Masami Hiramatsuab40c5c2007-01-30 14:36:06 -0800259 kip->slot_used[i] = SLOT_DIRTY;
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800260 kip->ngarbage++;
261 } else {
262 collect_one_slot(kip, i);
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700263 }
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800264 break;
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700265 }
266 }
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700267
268 if (dirty && ++kprobe_garbage_slots > INSNS_PER_PAGE)
Masami Hiramatsub4c6c342006-12-06 20:38:11 -0800269 collect_garbage_slots();
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700270}
Anil S Keshavamurthy2d14e392006-01-09 20:52:41 -0800271#endif
Ananth N Mavinakayanahalli9ec4b1f2005-06-27 15:17:01 -0700272
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800273/* We have preemption disabled.. so it is safe to use __ versions */
274static inline void set_kprobe_instance(struct kprobe *kp)
275{
276 __get_cpu_var(kprobe_instance) = kp;
277}
278
279static inline void reset_kprobe_instance(void)
280{
281 __get_cpu_var(kprobe_instance) = NULL;
282}
283
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800284/*
285 * This routine is called either:
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800286 * - under the kprobe_mutex - during kprobe_[un]register()
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800287 * OR
Ananth N Mavinakayanahallid217d542005-11-07 01:00:14 -0800288 * - with preemption disabled - from arch/xxx/kernel/kprobes.c
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800289 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700290struct kprobe __kprobes *get_kprobe(void *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
292 struct hlist_head *head;
293 struct hlist_node *node;
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800294 struct kprobe *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800297 hlist_for_each_entry_rcu(p, node, head, hlist) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 if (p->addr == addr)
299 return p;
300 }
301 return NULL;
302}
303
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700304/*
305 * Aggregate handlers for multiple kprobes support - these handlers
306 * take care of invoking the individual kprobe handlers on p->list
307 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700308static int __kprobes aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700309{
310 struct kprobe *kp;
311
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800312 list_for_each_entry_rcu(kp, &p->list, list) {
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700313 if (kp->pre_handler) {
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800314 set_kprobe_instance(kp);
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700315 if (kp->pre_handler(kp, regs))
316 return 1;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700317 }
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800318 reset_kprobe_instance();
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700319 }
320 return 0;
321}
322
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700323static void __kprobes aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
324 unsigned long flags)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700325{
326 struct kprobe *kp;
327
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800328 list_for_each_entry_rcu(kp, &p->list, list) {
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700329 if (kp->post_handler) {
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800330 set_kprobe_instance(kp);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700331 kp->post_handler(kp, regs, flags);
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800332 reset_kprobe_instance();
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700333 }
334 }
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700335}
336
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700337static int __kprobes aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
338 int trapnr)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700339{
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800340 struct kprobe *cur = __get_cpu_var(kprobe_instance);
341
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700342 /*
343 * if we faulted "during" the execution of a user specified
344 * probe handler, invoke just that probe's fault handler
345 */
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800346 if (cur && cur->fault_handler) {
347 if (cur->fault_handler(cur, regs, trapnr))
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700348 return 1;
349 }
350 return 0;
351}
352
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700353static int __kprobes aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700354{
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800355 struct kprobe *cur = __get_cpu_var(kprobe_instance);
356 int ret = 0;
357
358 if (cur && cur->break_handler) {
359 if (cur->break_handler(cur, regs))
360 ret = 1;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700361 }
Ananth N Mavinakayanahallie6584522005-11-07 01:00:07 -0800362 reset_kprobe_instance();
363 return ret;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700364}
365
Keshavamurthy Anil Sbf8d5c52005-12-12 00:37:34 -0800366/* Walks the list and increments nmissed count for multiprobe case */
367void __kprobes kprobes_inc_nmissed_count(struct kprobe *p)
368{
369 struct kprobe *kp;
370 if (p->pre_handler != aggr_pre_handler) {
371 p->nmissed++;
372 } else {
373 list_for_each_entry_rcu(kp, &p->list, list)
374 kp->nmissed++;
375 }
376 return;
377}
378
bibo,mao99219a32006-10-02 02:17:35 -0700379void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
380 struct hlist_head *head)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700381{
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700382 struct kretprobe *rp = ri->rp;
383
Hien Nguyenb94cce92005-06-23 00:09:19 -0700384 /* remove rp inst off the rprobe_inst_table */
385 hlist_del(&ri->hlist);
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700386 INIT_HLIST_NODE(&ri->hlist);
387 if (likely(rp)) {
388 spin_lock(&rp->lock);
389 hlist_add_head(&ri->hlist, &rp->free_instances);
390 spin_unlock(&rp->lock);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700391 } else
392 /* Unregistering */
bibo,mao99219a32006-10-02 02:17:35 -0700393 hlist_add_head(&ri->hlist, head);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700394}
395
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700396void kretprobe_hash_lock(struct task_struct *tsk,
397 struct hlist_head **head, unsigned long *flags)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700398{
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700399 unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
400 spinlock_t *hlist_lock;
401
402 *head = &kretprobe_inst_table[hash];
403 hlist_lock = kretprobe_table_lock_ptr(hash);
404 spin_lock_irqsave(hlist_lock, *flags);
405}
406
Adrian Bunk2b252c52008-10-15 22:05:20 -0700407static void kretprobe_table_lock(unsigned long hash, unsigned long *flags)
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700408{
409 spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
410 spin_lock_irqsave(hlist_lock, *flags);
411}
412
413void kretprobe_hash_unlock(struct task_struct *tsk, unsigned long *flags)
414{
415 unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
416 spinlock_t *hlist_lock;
417
418 hlist_lock = kretprobe_table_lock_ptr(hash);
419 spin_unlock_irqrestore(hlist_lock, *flags);
420}
421
422void kretprobe_table_unlock(unsigned long hash, unsigned long *flags)
423{
424 spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
425 spin_unlock_irqrestore(hlist_lock, *flags);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700426}
427
Hien Nguyenb94cce92005-06-23 00:09:19 -0700428/*
bibo maoc6fd91f2006-03-26 01:38:20 -0800429 * This function is called from finish_task_switch when task tk becomes dead,
430 * so that we can recycle any function-return probe instances associated
431 * with this task. These left over instances represent probed functions
432 * that have been called but will never return.
Hien Nguyenb94cce92005-06-23 00:09:19 -0700433 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700434void __kprobes kprobe_flush_task(struct task_struct *tk)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700435{
bibo,mao62c27be2006-10-02 02:17:33 -0700436 struct kretprobe_instance *ri;
bibo,mao99219a32006-10-02 02:17:35 -0700437 struct hlist_head *head, empty_rp;
Rusty Lynch802eae72005-06-27 15:17:08 -0700438 struct hlist_node *node, *tmp;
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700439 unsigned long hash, flags = 0;
Rusty Lynch802eae72005-06-27 15:17:08 -0700440
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700441 if (unlikely(!kprobes_initialized))
442 /* Early boot. kretprobe_table_locks not yet initialized. */
443 return;
444
445 hash = hash_ptr(tk, KPROBE_HASH_BITS);
446 head = &kretprobe_inst_table[hash];
447 kretprobe_table_lock(hash, &flags);
bibo,mao62c27be2006-10-02 02:17:33 -0700448 hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
449 if (ri->task == tk)
bibo,mao99219a32006-10-02 02:17:35 -0700450 recycle_rp_inst(ri, &empty_rp);
bibo,mao62c27be2006-10-02 02:17:33 -0700451 }
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700452 kretprobe_table_unlock(hash, &flags);
453 INIT_HLIST_HEAD(&empty_rp);
bibo,mao99219a32006-10-02 02:17:35 -0700454 hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
455 hlist_del(&ri->hlist);
456 kfree(ri);
457 }
Hien Nguyenb94cce92005-06-23 00:09:19 -0700458}
459
Hien Nguyenb94cce92005-06-23 00:09:19 -0700460static inline void free_rp_inst(struct kretprobe *rp)
461{
462 struct kretprobe_instance *ri;
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700463 struct hlist_node *pos, *next;
464
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700465 hlist_for_each_entry_safe(ri, pos, next, &rp->free_instances, hlist) {
466 hlist_del(&ri->hlist);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700467 kfree(ri);
468 }
469}
470
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700471static void __kprobes cleanup_rp_inst(struct kretprobe *rp)
472{
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700473 unsigned long flags, hash;
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700474 struct kretprobe_instance *ri;
475 struct hlist_node *pos, *next;
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700476 struct hlist_head *head;
477
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700478 /* No race here */
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700479 for (hash = 0; hash < KPROBE_TABLE_SIZE; hash++) {
480 kretprobe_table_lock(hash, &flags);
481 head = &kretprobe_inst_table[hash];
482 hlist_for_each_entry_safe(ri, pos, next, head, hlist) {
483 if (ri->rp == rp)
484 ri->rp = NULL;
485 }
486 kretprobe_table_unlock(hash, &flags);
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700487 }
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700488 free_rp_inst(rp);
489}
490
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700491/*
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700492 * Keep all fields in the kprobe consistent
493 */
494static inline void copy_kprobe(struct kprobe *old_p, struct kprobe *p)
495{
496 memcpy(&p->opcode, &old_p->opcode, sizeof(kprobe_opcode_t));
497 memcpy(&p->ainsn, &old_p->ainsn, sizeof(struct arch_specific_insn));
498}
499
500/*
501* Add the new probe to old_p->list. Fail if this is the
502* second jprobe at the address - two jprobes can't coexist
503*/
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700504static int __kprobes add_new_kprobe(struct kprobe *old_p, struct kprobe *p)
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700505{
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700506 if (p->break_handler) {
mao, bibo36721652006-06-26 00:25:22 -0700507 if (old_p->break_handler)
508 return -EEXIST;
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800509 list_add_tail_rcu(&p->list, &old_p->list);
mao, bibo36721652006-06-26 00:25:22 -0700510 old_p->break_handler = aggr_break_handler;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700511 } else
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800512 list_add_rcu(&p->list, &old_p->list);
mao, bibo36721652006-06-26 00:25:22 -0700513 if (p->post_handler && !old_p->post_handler)
514 old_p->post_handler = aggr_post_handler;
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700515 return 0;
516}
517
518/*
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700519 * Fill in the required fields of the "manager kprobe". Replace the
520 * earlier kprobe in the hlist with the manager kprobe
521 */
522static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
523{
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700524 copy_kprobe(p, ap);
bibo, maoa9ad9652006-07-30 03:03:26 -0700525 flush_insn_slot(ap);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700526 ap->addr = p->addr;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700527 ap->pre_handler = aggr_pre_handler;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700528 ap->fault_handler = aggr_fault_handler;
mao, bibo36721652006-06-26 00:25:22 -0700529 if (p->post_handler)
530 ap->post_handler = aggr_post_handler;
531 if (p->break_handler)
532 ap->break_handler = aggr_break_handler;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700533
534 INIT_LIST_HEAD(&ap->list);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800535 list_add_rcu(&p->list, &ap->list);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700536
Keshavamurthy Anil Sadad0f32005-12-12 00:37:12 -0800537 hlist_replace_rcu(&p->hlist, &ap->hlist);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700538}
539
540/*
541 * This is the second or subsequent kprobe at the address - handle
542 * the intricacies
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700543 */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700544static int __kprobes register_aggr_kprobe(struct kprobe *old_p,
545 struct kprobe *p)
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700546{
547 int ret = 0;
548 struct kprobe *ap;
549
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700550 if (old_p->pre_handler == aggr_pre_handler) {
551 copy_kprobe(old_p, p);
552 ret = add_new_kprobe(old_p, p);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700553 } else {
Keshavamurthy Anil Sa0d50062006-01-09 20:52:46 -0800554 ap = kzalloc(sizeof(struct kprobe), GFP_KERNEL);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700555 if (!ap)
556 return -ENOMEM;
557 add_aggr_kprobe(ap, old_p);
Prasanna S Panchamukhi8b0914e2005-06-23 00:09:41 -0700558 copy_kprobe(ap, p);
559 ret = add_new_kprobe(ap, p);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700560 }
561 return ret;
562}
563
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700564static int __kprobes in_kprobes_functions(unsigned long addr)
565{
Srinivasa Ds3d8d9962008-04-28 02:14:26 -0700566 struct kprobe_blackpoint *kb;
567
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700568 if (addr >= (unsigned long)__kprobes_text_start &&
569 addr < (unsigned long)__kprobes_text_end)
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700570 return -EINVAL;
Srinivasa Ds3d8d9962008-04-28 02:14:26 -0700571 /*
572 * If there exists a kprobe_blacklist, verify and
573 * fail any probe registration in the prohibited area
574 */
575 for (kb = kprobe_blacklist; kb->name != NULL; kb++) {
576 if (kb->start_addr) {
577 if (addr >= kb->start_addr &&
578 addr < (kb->start_addr + kb->range))
579 return -EINVAL;
580 }
581 }
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700582 return 0;
583}
584
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800585/*
586 * If we have a symbol_name argument, look it up and add the offset field
587 * to it. This way, we can specify a relative address to a symbol.
588 */
589static kprobe_opcode_t __kprobes *kprobe_addr(struct kprobe *p)
590{
591 kprobe_opcode_t *addr = p->addr;
592 if (p->symbol_name) {
593 if (addr)
594 return NULL;
595 kprobe_lookup_name(p->symbol_name, addr);
596 }
597
598 if (!addr)
599 return NULL;
600 return (kprobe_opcode_t *)(((char *)addr) + p->offset);
601}
602
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800603static int __kprobes __register_kprobe(struct kprobe *p,
604 unsigned long called_from)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605{
606 int ret = 0;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700607 struct kprobe *old_p;
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800608 struct module *probed_mod;
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800609 kprobe_opcode_t *addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800611 addr = kprobe_addr(p);
612 if (!addr)
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -0700613 return -EINVAL;
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800614 p->addr = addr;
Ananth N Mavinakayanahalli3a872d82006-10-02 02:17:30 -0700615
Masami Hiramatsua189d032008-11-12 13:26:51 -0800616 preempt_disable();
617 if (!__kernel_text_address((unsigned long) p->addr) ||
618 in_kprobes_functions((unsigned long) p->addr)) {
619 preempt_enable();
Mao, Bibob3e55c72005-12-12 00:37:00 -0800620 return -EINVAL;
Masami Hiramatsua189d032008-11-12 13:26:51 -0800621 }
Mao, Bibob3e55c72005-12-12 00:37:00 -0800622
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800623 p->mod_refcounted = 0;
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700624
625 /*
626 * Check if are we probing a module.
627 */
Masami Hiramatsua189d032008-11-12 13:26:51 -0800628 probed_mod = __module_text_address((unsigned long) p->addr);
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700629 if (probed_mod) {
Masami Hiramatsua189d032008-11-12 13:26:51 -0800630 struct module *calling_mod;
631 calling_mod = __module_text_address(called_from);
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700632 /*
633 * We must allow modules to probe themself and in this case
634 * avoid incrementing the module refcount, so as to allow
635 * unloading of self probing modules.
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800636 */
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700637 if (calling_mod && calling_mod != probed_mod) {
Masami Hiramatsua189d032008-11-12 13:26:51 -0800638 if (unlikely(!try_module_get(probed_mod))) {
639 preempt_enable();
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800640 return -EINVAL;
Masami Hiramatsua189d032008-11-12 13:26:51 -0800641 }
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800642 p->mod_refcounted = 1;
643 } else
644 probed_mod = NULL;
645 }
Masami Hiramatsua189d032008-11-12 13:26:51 -0800646 preempt_enable();
Mao, Bibob3e55c72005-12-12 00:37:00 -0800647
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800648 p->nmissed = 0;
Masami Hiramatsu98616682008-04-28 02:14:28 -0700649 INIT_LIST_HEAD(&p->list);
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800650 mutex_lock(&kprobe_mutex);
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700651 old_p = get_kprobe(p->addr);
652 if (old_p) {
653 ret = register_aggr_kprobe(old_p, p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 goto out;
655 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700657 ret = arch_prepare_kprobe(p);
658 if (ret)
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800659 goto out;
660
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700661 INIT_HLIST_NODE(&p->hlist);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800662 hlist_add_head_rcu(&p->hlist,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
664
Christoph Hellwig74a0b572007-10-16 01:24:07 -0700665 if (kprobe_enabled)
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -0700666 arch_arm_kprobe(p);
Christoph Hellwig74a0b572007-10-16 01:24:07 -0700667
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668out:
Ingo Molnar7a7d1cf2006-03-23 03:00:35 -0800669 mutex_unlock(&kprobe_mutex);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800670
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800671 if (ret && probed_mod)
672 module_put(probed_mod);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 return ret;
674}
675
Masami Hiramatsu98616682008-04-28 02:14:28 -0700676/*
677 * Unregister a kprobe without a scheduler synchronization.
678 */
679static int __kprobes __unregister_kprobe_top(struct kprobe *p)
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800680{
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800681 struct kprobe *old_p, *list_p;
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700682
Ananth N Mavinakayanahalli64f562c2005-05-05 16:15:42 -0700683 old_p = get_kprobe(p->addr);
Masami Hiramatsu98616682008-04-28 02:14:28 -0700684 if (unlikely(!old_p))
685 return -EINVAL;
686
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800687 if (p != old_p) {
688 list_for_each_entry_rcu(list_p, &old_p->list, list)
689 if (list_p == p)
690 /* kprobe p is a valid probe */
691 goto valid_p;
Masami Hiramatsu98616682008-04-28 02:14:28 -0700692 return -EINVAL;
Keshavamurthy Anil Sf709b122006-01-09 20:52:44 -0800693 }
694valid_p:
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700695 if (old_p == p ||
696 (old_p->pre_handler == aggr_pre_handler &&
Masami Hiramatsu98616682008-04-28 02:14:28 -0700697 list_is_singular(&old_p->list))) {
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -0700698 /*
699 * Only probe on the hash list. Disarm only if kprobes are
700 * enabled - otherwise, the breakpoint would already have
701 * been removed. We save on flushing icache.
702 */
703 if (kprobe_enabled)
704 arch_disarm_kprobe(p);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800705 hlist_del_rcu(&old_p->hlist);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800706 } else {
Masami Hiramatsu98616682008-04-28 02:14:28 -0700707 if (p->break_handler)
708 old_p->break_handler = NULL;
709 if (p->post_handler) {
710 list_for_each_entry_rcu(list_p, &old_p->list, list) {
711 if ((list_p != p) && (list_p->post_handler))
712 goto noclean;
713 }
714 old_p->post_handler = NULL;
715 }
716noclean:
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800717 list_del_rcu(&p->list);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800718 }
Masami Hiramatsu98616682008-04-28 02:14:28 -0700719 return 0;
720}
Mao, Bibob3e55c72005-12-12 00:37:00 -0800721
Masami Hiramatsu98616682008-04-28 02:14:28 -0700722static void __kprobes __unregister_kprobe_bottom(struct kprobe *p)
723{
724 struct module *mod;
725 struct kprobe *old_p;
Mao, Bibob3e55c72005-12-12 00:37:00 -0800726
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700727 if (p->mod_refcounted) {
Masami Hiramatsua189d032008-11-12 13:26:51 -0800728 /*
729 * Since we've already incremented refcount,
730 * we don't need to disable preemption.
731 */
Christoph Hellwig6f716ac2007-05-08 00:34:13 -0700732 mod = module_text_address((unsigned long)p->addr);
733 if (mod)
734 module_put(mod);
735 }
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800736
Masami Hiramatsu98616682008-04-28 02:14:28 -0700737 if (list_empty(&p->list) || list_is_singular(&p->list)) {
738 if (!list_empty(&p->list)) {
739 /* "p" is the last child of an aggr_kprobe */
740 old_p = list_entry(p->list.next, struct kprobe, list);
741 list_del(&p->list);
Ananth N Mavinakayanahalli3516a462005-11-07 01:00:13 -0800742 kfree(old_p);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800743 }
Ananth N Mavinakayanahalli0498b632006-01-09 20:52:46 -0800744 arch_remove_kprobe(p);
Anil S Keshavamurthy49a2a1b2006-01-09 20:52:43 -0800745 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746}
747
Masami Hiramatsu98616682008-04-28 02:14:28 -0700748static int __register_kprobes(struct kprobe **kps, int num,
749 unsigned long called_from)
750{
751 int i, ret = 0;
752
753 if (num <= 0)
754 return -EINVAL;
755 for (i = 0; i < num; i++) {
756 ret = __register_kprobe(kps[i], called_from);
Masami Hiramatsu67dddaa2008-06-12 15:21:35 -0700757 if (ret < 0) {
758 if (i > 0)
759 unregister_kprobes(kps, i);
Masami Hiramatsu98616682008-04-28 02:14:28 -0700760 break;
761 }
762 }
763 return ret;
764}
765
766/*
767 * Registration and unregistration functions for kprobe.
768 */
769int __kprobes register_kprobe(struct kprobe *p)
770{
771 return __register_kprobes(&p, 1,
772 (unsigned long)__builtin_return_address(0));
773}
774
775void __kprobes unregister_kprobe(struct kprobe *p)
776{
777 unregister_kprobes(&p, 1);
778}
779
780int __kprobes register_kprobes(struct kprobe **kps, int num)
781{
782 return __register_kprobes(kps, num,
783 (unsigned long)__builtin_return_address(0));
784}
785
786void __kprobes unregister_kprobes(struct kprobe **kps, int num)
787{
788 int i;
789
790 if (num <= 0)
791 return;
792 mutex_lock(&kprobe_mutex);
793 for (i = 0; i < num; i++)
794 if (__unregister_kprobe_top(kps[i]) < 0)
795 kps[i]->addr = NULL;
796 mutex_unlock(&kprobe_mutex);
797
798 synchronize_sched();
799 for (i = 0; i < num; i++)
800 if (kps[i]->addr)
801 __unregister_kprobe_bottom(kps[i]);
802}
803
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804static struct notifier_block kprobe_exceptions_nb = {
805 .notifier_call = kprobe_exceptions_notify,
Anil S Keshavamurthy3d5631e2006-06-26 00:25:28 -0700806 .priority = 0x7fffffff /* we need to be notified first */
807};
808
Michael Ellerman3d7e3382007-07-19 01:48:11 -0700809unsigned long __weak arch_deref_entry_point(void *entry)
810{
811 return (unsigned long)entry;
812}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813
Masami Hiramatsu26b31c12008-04-28 02:14:29 -0700814static int __register_jprobes(struct jprobe **jps, int num,
815 unsigned long called_from)
816{
817 struct jprobe *jp;
818 int ret = 0, i;
819
820 if (num <= 0)
821 return -EINVAL;
822 for (i = 0; i < num; i++) {
823 unsigned long addr;
824 jp = jps[i];
825 addr = arch_deref_entry_point(jp->entry);
826
827 if (!kernel_text_address(addr))
828 ret = -EINVAL;
829 else {
830 /* Todo: Verify probepoint is a function entry point */
831 jp->kp.pre_handler = setjmp_pre_handler;
832 jp->kp.break_handler = longjmp_break_handler;
833 ret = __register_kprobe(&jp->kp, called_from);
834 }
Masami Hiramatsu67dddaa2008-06-12 15:21:35 -0700835 if (ret < 0) {
836 if (i > 0)
837 unregister_jprobes(jps, i);
Masami Hiramatsu26b31c12008-04-28 02:14:29 -0700838 break;
839 }
840 }
841 return ret;
842}
843
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700844int __kprobes register_jprobe(struct jprobe *jp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845{
Masami Hiramatsu26b31c12008-04-28 02:14:29 -0700846 return __register_jprobes(&jp, 1,
Keshavamurthy Anil Sdf019b12006-01-11 12:17:41 -0800847 (unsigned long)__builtin_return_address(0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848}
849
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700850void __kprobes unregister_jprobe(struct jprobe *jp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851{
Masami Hiramatsu26b31c12008-04-28 02:14:29 -0700852 unregister_jprobes(&jp, 1);
853}
854
855int __kprobes register_jprobes(struct jprobe **jps, int num)
856{
857 return __register_jprobes(jps, num,
858 (unsigned long)__builtin_return_address(0));
859}
860
861void __kprobes unregister_jprobes(struct jprobe **jps, int num)
862{
863 int i;
864
865 if (num <= 0)
866 return;
867 mutex_lock(&kprobe_mutex);
868 for (i = 0; i < num; i++)
869 if (__unregister_kprobe_top(&jps[i]->kp) < 0)
870 jps[i]->kp.addr = NULL;
871 mutex_unlock(&kprobe_mutex);
872
873 synchronize_sched();
874 for (i = 0; i < num; i++) {
875 if (jps[i]->kp.addr)
876 __unregister_kprobe_bottom(&jps[i]->kp);
877 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878}
879
Ananth N Mavinakayanahalli9edddaa2008-03-04 14:28:37 -0800880#ifdef CONFIG_KRETPROBES
Adrian Bunke65cefe2006-02-03 03:03:42 -0800881/*
882 * This kprobe pre_handler is registered with every kretprobe. When probe
883 * hits it will set up the return probe.
884 */
885static int __kprobes pre_handler_kretprobe(struct kprobe *p,
886 struct pt_regs *regs)
887{
888 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700889 unsigned long hash, flags = 0;
890 struct kretprobe_instance *ri;
Adrian Bunke65cefe2006-02-03 03:03:42 -0800891
892 /*TODO: consider to only swap the RA after the last pre_handler fired */
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700893 hash = hash_ptr(current, KPROBE_HASH_BITS);
894 spin_lock_irqsave(&rp->lock, flags);
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700895 if (!hlist_empty(&rp->free_instances)) {
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700896 ri = hlist_entry(rp->free_instances.first,
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700897 struct kretprobe_instance, hlist);
898 hlist_del(&ri->hlist);
899 spin_unlock_irqrestore(&rp->lock, flags);
900
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700901 ri->rp = rp;
902 ri->task = current;
Abhishek Sagarf47cd9b2008-02-06 01:38:22 -0800903
904 if (rp->entry_handler && rp->entry_handler(ri, regs)) {
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700905 spin_unlock_irqrestore(&rp->lock, flags);
Abhishek Sagarf47cd9b2008-02-06 01:38:22 -0800906 return 0;
907 }
908
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700909 arch_prepare_kretprobe(ri, regs);
910
911 /* XXX(hch): why is there no hlist_move_head? */
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700912 INIT_HLIST_NODE(&ri->hlist);
913 kretprobe_table_lock(hash, &flags);
914 hlist_add_head(&ri->hlist, &kretprobe_inst_table[hash]);
915 kretprobe_table_unlock(hash, &flags);
916 } else {
Christoph Hellwig4c4308c2007-05-08 00:34:14 -0700917 rp->nmissed++;
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700918 spin_unlock_irqrestore(&rp->lock, flags);
919 }
Adrian Bunke65cefe2006-02-03 03:03:42 -0800920 return 0;
921}
922
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700923static int __kprobes __register_kretprobe(struct kretprobe *rp,
924 unsigned long called_from)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700925{
926 int ret = 0;
927 struct kretprobe_instance *inst;
928 int i;
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800929 void *addr;
Masami Hiramatsuf438d912007-10-16 01:27:49 -0700930
931 if (kretprobe_blacklist_size) {
Masami Hiramatsub2a5cd62008-03-04 14:29:44 -0800932 addr = kprobe_addr(&rp->kp);
933 if (!addr)
934 return -EINVAL;
Masami Hiramatsuf438d912007-10-16 01:27:49 -0700935
936 for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
937 if (kretprobe_blacklist[i].addr == addr)
938 return -EINVAL;
939 }
940 }
Hien Nguyenb94cce92005-06-23 00:09:19 -0700941
942 rp->kp.pre_handler = pre_handler_kretprobe;
Ananth N Mavinakayanahalli7522a842006-04-20 02:43:11 -0700943 rp->kp.post_handler = NULL;
944 rp->kp.fault_handler = NULL;
945 rp->kp.break_handler = NULL;
Hien Nguyenb94cce92005-06-23 00:09:19 -0700946
947 /* Pre-allocate memory for max kretprobe instances */
948 if (rp->maxactive <= 0) {
949#ifdef CONFIG_PREEMPT
950 rp->maxactive = max(10, 2 * NR_CPUS);
951#else
952 rp->maxactive = NR_CPUS;
953#endif
954 }
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700955 spin_lock_init(&rp->lock);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700956 INIT_HLIST_HEAD(&rp->free_instances);
957 for (i = 0; i < rp->maxactive; i++) {
Abhishek Sagarf47cd9b2008-02-06 01:38:22 -0800958 inst = kmalloc(sizeof(struct kretprobe_instance) +
959 rp->data_size, GFP_KERNEL);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700960 if (inst == NULL) {
961 free_rp_inst(rp);
962 return -ENOMEM;
963 }
Srinivasa D Sef53d9c2008-07-25 01:46:04 -0700964 INIT_HLIST_NODE(&inst->hlist);
965 hlist_add_head(&inst->hlist, &rp->free_instances);
Hien Nguyenb94cce92005-06-23 00:09:19 -0700966 }
967
968 rp->nmissed = 0;
969 /* Establish function entry probe point */
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700970 ret = __register_kprobe(&rp->kp, called_from);
971 if (ret != 0)
Hien Nguyenb94cce92005-06-23 00:09:19 -0700972 free_rp_inst(rp);
973 return ret;
974}
975
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700976static int __register_kretprobes(struct kretprobe **rps, int num,
977 unsigned long called_from)
978{
979 int ret = 0, i;
980
981 if (num <= 0)
982 return -EINVAL;
983 for (i = 0; i < num; i++) {
984 ret = __register_kretprobe(rps[i], called_from);
Masami Hiramatsu67dddaa2008-06-12 15:21:35 -0700985 if (ret < 0) {
986 if (i > 0)
987 unregister_kretprobes(rps, i);
Masami Hiramatsu4a296e02008-04-28 02:14:29 -0700988 break;
989 }
990 }
991 return ret;
992}
993
994int __kprobes register_kretprobe(struct kretprobe *rp)
995{
996 return __register_kretprobes(&rp, 1,
997 (unsigned long)__builtin_return_address(0));
998}
999
1000void __kprobes unregister_kretprobe(struct kretprobe *rp)
1001{
1002 unregister_kretprobes(&rp, 1);
1003}
1004
1005int __kprobes register_kretprobes(struct kretprobe **rps, int num)
1006{
1007 return __register_kretprobes(rps, num,
1008 (unsigned long)__builtin_return_address(0));
1009}
1010
1011void __kprobes unregister_kretprobes(struct kretprobe **rps, int num)
1012{
1013 int i;
1014
1015 if (num <= 0)
1016 return;
1017 mutex_lock(&kprobe_mutex);
1018 for (i = 0; i < num; i++)
1019 if (__unregister_kprobe_top(&rps[i]->kp) < 0)
1020 rps[i]->kp.addr = NULL;
1021 mutex_unlock(&kprobe_mutex);
1022
1023 synchronize_sched();
1024 for (i = 0; i < num; i++) {
1025 if (rps[i]->kp.addr) {
1026 __unregister_kprobe_bottom(&rps[i]->kp);
1027 cleanup_rp_inst(rps[i]);
1028 }
1029 }
1030}
1031
Ananth N Mavinakayanahalli9edddaa2008-03-04 14:28:37 -08001032#else /* CONFIG_KRETPROBES */
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -07001033int __kprobes register_kretprobe(struct kretprobe *rp)
Hien Nguyenb94cce92005-06-23 00:09:19 -07001034{
1035 return -ENOSYS;
1036}
1037
Masami Hiramatsu4a296e02008-04-28 02:14:29 -07001038int __kprobes register_kretprobes(struct kretprobe **rps, int num)
1039{
1040 return -ENOSYS;
1041}
1042void __kprobes unregister_kretprobe(struct kretprobe *rp)
1043{
1044}
1045
1046void __kprobes unregister_kretprobes(struct kretprobe **rps, int num)
1047{
1048}
1049
Srinivasa Ds346fd592007-02-20 13:57:54 -08001050static int __kprobes pre_handler_kretprobe(struct kprobe *p,
1051 struct pt_regs *regs)
1052{
1053 return 0;
1054}
Masami Hiramatsu4a296e02008-04-28 02:14:29 -07001055
Ananth N Mavinakayanahalli9edddaa2008-03-04 14:28:37 -08001056#endif /* CONFIG_KRETPROBES */
Hien Nguyenb94cce92005-06-23 00:09:19 -07001057
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058static int __init init_kprobes(void)
1059{
1060 int i, err = 0;
Srinivasa Ds3d8d9962008-04-28 02:14:26 -07001061 unsigned long offset = 0, size = 0;
1062 char *modname, namebuf[128];
1063 const char *symbol_name;
1064 void *addr;
1065 struct kprobe_blackpoint *kb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066
1067 /* FIXME allocate the probe table, currently defined statically */
1068 /* initialize all list heads */
Hien Nguyenb94cce92005-06-23 00:09:19 -07001069 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 INIT_HLIST_HEAD(&kprobe_table[i]);
Hien Nguyenb94cce92005-06-23 00:09:19 -07001071 INIT_HLIST_HEAD(&kretprobe_inst_table[i]);
Srinivasa D Sef53d9c2008-07-25 01:46:04 -07001072 spin_lock_init(&(kretprobe_table_locks[i].lock));
Hien Nguyenb94cce92005-06-23 00:09:19 -07001073 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074
Srinivasa Ds3d8d9962008-04-28 02:14:26 -07001075 /*
1076 * Lookup and populate the kprobe_blacklist.
1077 *
1078 * Unlike the kretprobe blacklist, we'll need to determine
1079 * the range of addresses that belong to the said functions,
1080 * since a kprobe need not necessarily be at the beginning
1081 * of a function.
1082 */
1083 for (kb = kprobe_blacklist; kb->name != NULL; kb++) {
1084 kprobe_lookup_name(kb->name, addr);
1085 if (!addr)
1086 continue;
1087
1088 kb->start_addr = (unsigned long)addr;
1089 symbol_name = kallsyms_lookup(kb->start_addr,
1090 &size, &offset, &modname, namebuf);
1091 if (!symbol_name)
1092 kb->range = 0;
1093 else
1094 kb->range = size;
1095 }
1096
Masami Hiramatsuf438d912007-10-16 01:27:49 -07001097 if (kretprobe_blacklist_size) {
1098 /* lookup the function address from its name */
1099 for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
1100 kprobe_lookup_name(kretprobe_blacklist[i].name,
1101 kretprobe_blacklist[i].addr);
1102 if (!kretprobe_blacklist[i].addr)
1103 printk("kretprobe: lookup failed: %s\n",
1104 kretprobe_blacklist[i].name);
1105 }
1106 }
1107
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001108 /* By default, kprobes are enabled */
1109 kprobe_enabled = true;
1110
Rusty Lynch67729262005-07-05 18:54:50 -07001111 err = arch_init_kprobes();
Rusty Lynch802eae72005-06-27 15:17:08 -07001112 if (!err)
1113 err = register_die_notifier(&kprobe_exceptions_nb);
Srinivasa D Sef53d9c2008-07-25 01:46:04 -07001114 kprobes_initialized = (err == 0);
Rusty Lynch802eae72005-06-27 15:17:08 -07001115
Ananth N Mavinakayanahalli8c1c9352008-01-30 13:32:53 +01001116 if (!err)
1117 init_test_probes();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 return err;
1119}
1120
Srinivasa Ds346fd592007-02-20 13:57:54 -08001121#ifdef CONFIG_DEBUG_FS
1122static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001123 const char *sym, int offset,char *modname)
Srinivasa Ds346fd592007-02-20 13:57:54 -08001124{
1125 char *kprobe_type;
1126
1127 if (p->pre_handler == pre_handler_kretprobe)
1128 kprobe_type = "r";
1129 else if (p->pre_handler == setjmp_pre_handler)
1130 kprobe_type = "j";
1131 else
1132 kprobe_type = "k";
1133 if (sym)
1134 seq_printf(pi, "%p %s %s+0x%x %s\n", p->addr, kprobe_type,
1135 sym, offset, (modname ? modname : " "));
1136 else
1137 seq_printf(pi, "%p %s %p\n", p->addr, kprobe_type, p->addr);
1138}
1139
1140static void __kprobes *kprobe_seq_start(struct seq_file *f, loff_t *pos)
1141{
1142 return (*pos < KPROBE_TABLE_SIZE) ? pos : NULL;
1143}
1144
1145static void __kprobes *kprobe_seq_next(struct seq_file *f, void *v, loff_t *pos)
1146{
1147 (*pos)++;
1148 if (*pos >= KPROBE_TABLE_SIZE)
1149 return NULL;
1150 return pos;
1151}
1152
1153static void __kprobes kprobe_seq_stop(struct seq_file *f, void *v)
1154{
1155 /* Nothing to do */
1156}
1157
1158static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
1159{
1160 struct hlist_head *head;
1161 struct hlist_node *node;
1162 struct kprobe *p, *kp;
1163 const char *sym = NULL;
1164 unsigned int i = *(loff_t *) v;
Alexey Dobriyanffb45122007-05-08 00:28:41 -07001165 unsigned long offset = 0;
Srinivasa Ds346fd592007-02-20 13:57:54 -08001166 char *modname, namebuf[128];
1167
1168 head = &kprobe_table[i];
1169 preempt_disable();
1170 hlist_for_each_entry_rcu(p, node, head, hlist) {
Alexey Dobriyanffb45122007-05-08 00:28:41 -07001171 sym = kallsyms_lookup((unsigned long)p->addr, NULL,
Srinivasa Ds346fd592007-02-20 13:57:54 -08001172 &offset, &modname, namebuf);
1173 if (p->pre_handler == aggr_pre_handler) {
1174 list_for_each_entry_rcu(kp, &p->list, list)
1175 report_probe(pi, kp, sym, offset, modname);
1176 } else
1177 report_probe(pi, p, sym, offset, modname);
1178 }
1179 preempt_enable();
1180 return 0;
1181}
1182
1183static struct seq_operations kprobes_seq_ops = {
1184 .start = kprobe_seq_start,
1185 .next = kprobe_seq_next,
1186 .stop = kprobe_seq_stop,
1187 .show = show_kprobe_addr
1188};
1189
1190static int __kprobes kprobes_open(struct inode *inode, struct file *filp)
1191{
1192 return seq_open(filp, &kprobes_seq_ops);
1193}
1194
1195static struct file_operations debugfs_kprobes_operations = {
1196 .open = kprobes_open,
1197 .read = seq_read,
1198 .llseek = seq_lseek,
1199 .release = seq_release,
1200};
1201
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001202static void __kprobes enable_all_kprobes(void)
1203{
1204 struct hlist_head *head;
1205 struct hlist_node *node;
1206 struct kprobe *p;
1207 unsigned int i;
1208
1209 mutex_lock(&kprobe_mutex);
1210
1211 /* If kprobes are already enabled, just return */
1212 if (kprobe_enabled)
1213 goto already_enabled;
1214
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001215 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
1216 head = &kprobe_table[i];
1217 hlist_for_each_entry_rcu(p, node, head, hlist)
1218 arch_arm_kprobe(p);
1219 }
1220
1221 kprobe_enabled = true;
1222 printk(KERN_INFO "Kprobes globally enabled\n");
1223
1224already_enabled:
1225 mutex_unlock(&kprobe_mutex);
1226 return;
1227}
1228
1229static void __kprobes disable_all_kprobes(void)
1230{
1231 struct hlist_head *head;
1232 struct hlist_node *node;
1233 struct kprobe *p;
1234 unsigned int i;
1235
1236 mutex_lock(&kprobe_mutex);
1237
1238 /* If kprobes are already disabled, just return */
1239 if (!kprobe_enabled)
1240 goto already_disabled;
1241
1242 kprobe_enabled = false;
1243 printk(KERN_INFO "Kprobes globally disabled\n");
1244 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
1245 head = &kprobe_table[i];
1246 hlist_for_each_entry_rcu(p, node, head, hlist) {
1247 if (!arch_trampoline_kprobe(p))
1248 arch_disarm_kprobe(p);
1249 }
1250 }
1251
1252 mutex_unlock(&kprobe_mutex);
1253 /* Allow all currently running kprobes to complete */
1254 synchronize_sched();
Christoph Hellwig74a0b572007-10-16 01:24:07 -07001255 return;
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001256
1257already_disabled:
1258 mutex_unlock(&kprobe_mutex);
1259 return;
1260}
1261
1262/*
1263 * XXX: The debugfs bool file interface doesn't allow for callbacks
1264 * when the bool state is switched. We can reuse that facility when
1265 * available
1266 */
1267static ssize_t read_enabled_file_bool(struct file *file,
1268 char __user *user_buf, size_t count, loff_t *ppos)
1269{
1270 char buf[3];
1271
1272 if (kprobe_enabled)
1273 buf[0] = '1';
1274 else
1275 buf[0] = '0';
1276 buf[1] = '\n';
1277 buf[2] = 0x00;
1278 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
1279}
1280
1281static ssize_t write_enabled_file_bool(struct file *file,
1282 const char __user *user_buf, size_t count, loff_t *ppos)
1283{
1284 char buf[32];
1285 int buf_size;
1286
1287 buf_size = min(count, (sizeof(buf)-1));
1288 if (copy_from_user(buf, user_buf, buf_size))
1289 return -EFAULT;
1290
1291 switch (buf[0]) {
1292 case 'y':
1293 case 'Y':
1294 case '1':
1295 enable_all_kprobes();
1296 break;
1297 case 'n':
1298 case 'N':
1299 case '0':
1300 disable_all_kprobes();
1301 break;
1302 }
1303
1304 return count;
1305}
1306
1307static struct file_operations fops_kp = {
1308 .read = read_enabled_file_bool,
1309 .write = write_enabled_file_bool,
1310};
1311
Srinivasa Ds346fd592007-02-20 13:57:54 -08001312static int __kprobes debugfs_kprobe_init(void)
1313{
1314 struct dentry *dir, *file;
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001315 unsigned int value = 1;
Srinivasa Ds346fd592007-02-20 13:57:54 -08001316
1317 dir = debugfs_create_dir("kprobes", NULL);
1318 if (!dir)
1319 return -ENOMEM;
1320
Randy Dunlape3869792007-05-08 00:27:01 -07001321 file = debugfs_create_file("list", 0444, dir, NULL,
Srinivasa Ds346fd592007-02-20 13:57:54 -08001322 &debugfs_kprobes_operations);
1323 if (!file) {
1324 debugfs_remove(dir);
1325 return -ENOMEM;
1326 }
1327
Ananth N Mavinakayanahallibf8f6e5b2007-05-08 00:34:16 -07001328 file = debugfs_create_file("enabled", 0600, dir,
1329 &value, &fops_kp);
1330 if (!file) {
1331 debugfs_remove(dir);
1332 return -ENOMEM;
1333 }
1334
Srinivasa Ds346fd592007-02-20 13:57:54 -08001335 return 0;
1336}
1337
1338late_initcall(debugfs_kprobe_init);
1339#endif /* CONFIG_DEBUG_FS */
1340
1341module_init(init_kprobes);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342
1343EXPORT_SYMBOL_GPL(register_kprobe);
1344EXPORT_SYMBOL_GPL(unregister_kprobe);
Masami Hiramatsu98616682008-04-28 02:14:28 -07001345EXPORT_SYMBOL_GPL(register_kprobes);
1346EXPORT_SYMBOL_GPL(unregister_kprobes);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347EXPORT_SYMBOL_GPL(register_jprobe);
1348EXPORT_SYMBOL_GPL(unregister_jprobe);
Masami Hiramatsu26b31c12008-04-28 02:14:29 -07001349EXPORT_SYMBOL_GPL(register_jprobes);
1350EXPORT_SYMBOL_GPL(unregister_jprobes);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351EXPORT_SYMBOL_GPL(jprobe_return);
Hien Nguyenb94cce92005-06-23 00:09:19 -07001352EXPORT_SYMBOL_GPL(register_kretprobe);
1353EXPORT_SYMBOL_GPL(unregister_kretprobe);
Masami Hiramatsu4a296e02008-04-28 02:14:29 -07001354EXPORT_SYMBOL_GPL(register_kretprobes);
1355EXPORT_SYMBOL_GPL(unregister_kretprobes);