riscv/kprobe: reclaim insn_slot on kprobe unregistration
PATCH 1/1 riscv/kprobe: reclaim insn_slot on kprobe unregistration
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.
This bug reported by Chen Guokai <[email protected]>.
--- arch/riscv/kernel/probes/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/riscv/kernel/probes/kprobes.c +4 -0
@@ -110,6 +110,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)
Signature · 1 line
2.17.1
Quoted 3 lines · Liao Chang
On kprobe registration kernel allocate one
insn_slotfor new kprobe, but it forget to reclaim theinsn_sloton unregistration, leading to a potential leakage.
+ Guo Ren
Nice catch! I think csky needs the fix as well.
Quoted 2 lines
This bug reported by Chen Guokai <[email protected]>.
This needs a "Reported-by: ..." tag
Quoted 29 lines
Signed-off-by Liao Chang <[email protected]>--- arch/riscv/kernel/probes/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+)arch/riscv/kernel/probes/kprobes.c +4
-0@@ -110,6 +110,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)Signature · 7 lines
2.17.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 5 lines · Jisheng Zhang
Quoted 3 lines · Liao Chang
On kprobe registration kernel allocate one
insn_slotfor new kprobe, but it forget to reclaim theinsn_sloton unregistration, leading to a potential leakage.
Quoted 8 lines
+ Guo Ren
Nice catch! I think csky needs the fix as well.
Quoted 2 lines
This bug reported by Chen Guokai <[email protected]>.
This needs a "Reported-by: ..." tag
Thanks for comment.
Quoted 31 lines
Quoted 30 lines
Signed-off-by Liao Chang <[email protected]>--- arch/riscv/kernel/probes/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+)arch/riscv/kernel/probes/kprobes.c +4
-0@@ -110,6 +110,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)Signature · 7 lines
2.17.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv.
Signature · 2 lines
BR, Liao, Chang