kprobes: Free kretprobe_instance with RCU callback

Free kretprobe_instance with RCU callback instead of directly
freeing the object in the kretprobe handler context.

This will make kretprobe run safer in NMI context.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/159870616685.1229682.11978742048709542226.stgit@devnote2
This commit is contained in:
Masami Hiramatsu
2020-08-29 22:02:47 +09:00
committed by Ingo Molnar
parent e03b4a084e
commit b338817807
2 changed files with 10 additions and 21 deletions

View File

@@ -156,7 +156,10 @@ struct kretprobe {
};
struct kretprobe_instance {
struct hlist_node hlist;
union {
struct hlist_node hlist;
struct rcu_head rcu;
};
struct kretprobe *rp;
kprobe_opcode_t *ret_addr;
struct task_struct *task;
@@ -395,7 +398,6 @@ int register_kretprobes(struct kretprobe **rps, int num);
void unregister_kretprobes(struct kretprobe **rps, int num);
void kprobe_flush_task(struct task_struct *tk);
void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
int disable_kprobe(struct kprobe *kp);
int enable_kprobe(struct kprobe *kp);