Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105829
b: refs/heads/master
c: ef53d9c
h: refs/heads/master
i:
  105827: 512ee29
v: v3
  • Loading branch information
Srinivasa D S authored and Linus Torvalds committed Jul 25, 2008
1 parent 2b98455 commit 5825ddc
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 68 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53a9600c634e3bfd6230e0597aca159bf4d4d010
refs/heads/master: ef53d9c5e4da147ecaa43c44c5e5945eb83970a2
6 changes: 2 additions & 4 deletions trunk/arch/arm/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);

/*
* It is possible to have multiple instances associated with a given
Expand Down Expand Up @@ -337,7 +336,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
}

kretprobe_assert(ri, orig_ret_address, trampoline_address);
spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist);
Expand All @@ -347,7 +346,6 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
return (void *)orig_ret_address;
}

/* Called with kretprobe_lock held. */
void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
struct pt_regs *regs)
{
Expand Down
6 changes: 2 additions & 4 deletions trunk/arch/ia64/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
((struct fnptr *)kretprobe_trampoline)->ip;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);

/*
* It is possible to have multiple instances associated with a given
Expand Down Expand Up @@ -485,7 +484,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
kretprobe_assert(ri, orig_ret_address, trampoline_address);

reset_current_kprobe();
spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched();

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
Expand All @@ -500,7 +499,6 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
return 1;
}

/* Called with kretprobe_lock held */
void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
struct pt_regs *regs)
{
Expand Down
6 changes: 2 additions & 4 deletions trunk/arch/powerpc/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
kcb->kprobe_saved_msr = regs->msr;
}

/* Called with kretprobe_lock held */
void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -312,8 +311,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);

/*
* It is possible to have multiple instances associated with a given
Expand Down Expand Up @@ -352,7 +350,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
regs->nip = orig_ret_address;

reset_current_kprobe();
spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched();

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
Expand Down
6 changes: 2 additions & 4 deletions trunk/arch/s390/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
__ctl_store(kcb->kprobe_saved_ctl, 9, 11);
}

/* Called with kretprobe_lock held */
void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -377,8 +376,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);

/*
* It is possible to have multiple instances associated with a given
Expand Down Expand Up @@ -417,7 +415,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE;

reset_current_kprobe();
spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched();

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
Expand Down
11 changes: 5 additions & 6 deletions trunk/arch/sparc64/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
return 0;
}

/* Called with kretprobe_lock held. The value stored in the return
* address register is actually 2 instructions before where the
* callee will return to. Sequences usually look something like this
/* The value stored in the return address register is actually 2
* instructions before where the callee will return to.
* Sequences usually look something like this
*
* call some_function <--- return register points here
* nop <--- call delay slot
Expand Down Expand Up @@ -512,8 +512,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);

/*
* It is possible to have multiple instances associated with a given
Expand Down Expand Up @@ -553,7 +552,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
regs->tnpc = orig_ret_address + 4;

reset_current_kprobe();
spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);
preempt_enable_no_resched();

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
Expand Down
6 changes: 2 additions & 4 deletions trunk/arch/x86/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
regs->ip = (unsigned long)p->ainsn.insn;
}

/* Called with kretprobe_lock held */
void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -682,8 +681,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;

INIT_HLIST_HEAD(&empty_rp);
spin_lock_irqsave(&kretprobe_lock, flags);
head = kretprobe_inst_table_head(current);
kretprobe_hash_lock(current, &head, &flags);
/* fixup registers */
#ifdef CONFIG_X86_64
regs->cs = __KERNEL_CS;
Expand Down Expand Up @@ -732,7 +730,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs)

kretprobe_assert(ri, orig_ret_address, trampoline_address);

spin_unlock_irqrestore(&kretprobe_lock, flags);
kretprobe_hash_unlock(current, &flags);

hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
hlist_del(&ri->hlist);
Expand Down
7 changes: 4 additions & 3 deletions trunk/include/linux/kprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ struct kretprobe {
int nmissed;
size_t data_size;
struct hlist_head free_instances;
struct hlist_head used_instances;
spinlock_t lock;
};

struct kretprobe_instance {
struct hlist_node uflist; /* either on free list or used list */
struct hlist_node hlist;
struct kretprobe *rp;
kprobe_opcode_t *ret_addr;
Expand Down Expand Up @@ -201,7 +200,6 @@ static inline int init_test_probes(void)
}
#endif /* CONFIG_KPROBES_SANITY_TEST */

extern spinlock_t kretprobe_lock;
extern struct mutex kprobe_mutex;
extern int arch_prepare_kprobe(struct kprobe *p);
extern void arch_arm_kprobe(struct kprobe *p);
Expand All @@ -214,6 +212,9 @@ extern void kprobes_inc_nmissed_count(struct kprobe *p);

/* Get the kprobe at this addr (if any) - called with preemption disabled */
struct kprobe *get_kprobe(void *addr);
void kretprobe_hash_lock(struct task_struct *tsk,
struct hlist_head **head, unsigned long *flags);
void kretprobe_hash_unlock(struct task_struct *tsk, unsigned long *flags);
struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);

/* kprobe_running() will just return the current_kprobe on this CPU */
Expand Down
Loading

0 comments on commit 5825ddc

Please sign in to comment.