[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20220527003330.68f1fc0f58ecec812a7d037e@kernel.org>
Date: Fri, 27 May 2022 00:33:30 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Liao Chang <liaochang1@...wei.com>
Cc: <paul.walmsley@...ive.com>, <palmer@...belt.com>,
<aou@...s.berkeley.edu>, <rostedt@...dmis.org>,
<peterz@...radead.org>, <naveen.n.rao@...ux.vnet.ibm.com>,
<jszhang@...nel.org>, <guoren@...nel.org>,
<linux-riscv@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] riscv/kprobe: reclaim insn_slot on kprobe
unregistration
On Wed, 25 May 2022 09:44:24 +0800
Liao Chang <liaochang1@...wei.com> wrote:
> 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@...ls.ucas.ac.cn>
> Signed-off-by: Liao Chang <liaochang1@...wei.com>
Looks good to me.
Fixes: c22b0bcb1dd0 ("riscv: Add kprobes supported")
Cc: stable@...r.kernel.org
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Thank you,
> ---
> v2:
> Add Reported-by tag
>
> arch/riscv/kernel/probes/kprobes.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
> index e6e950b7cf32..f12eb1fbb52c 100644
> --- a/arch/riscv/kernel/probes/kprobes.c
> +++ b/arch/riscv/kernel/probes/kprobes.c
> @@ -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)
> --
> 2.17.1
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists