Skip to content

Commit

Permalink
csky/kprobe: reclaim insn_slot on kprobe unregistration
Browse files Browse the repository at this point in the history
[ Upstream commit a2310c7 ]

On kprobe registration kernel allocate one insn_slot for new kprobe,
but it forget to reclaim the insn_slot on unregistration, leading to a
potential leakage.

Reported-by: Chen Guokai <chenguokai17@mails.ucas.ac.cn>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Liao Chang <liaochang1@huawei.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Liao Chang authored and gregkh committed Aug 25, 2022
1 parent 0a5e368 commit e0cd4d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/csky/kernel/probes/kprobes.c
Expand Up @@ -124,6 +124,10 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)

void __kprobes arch_remove_kprobe(struct kprobe *p)
{
if (p->ainsn.api.insn) {
free_insn_slot(p->ainsn.api.insn, 0);
p->ainsn.api.insn = NULL;
}
}

static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
Expand Down

0 comments on commit e0cd4d1

Please sign in to comment.