* [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
@ 2022-05-23 1:51 ` Liao Chang
0 siblings, 0 replies; 6+ messages in thread
From: Liao Chang @ 2022-05-23 1:51 UTC (permalink / raw)
To: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz, jszhang,
liaochang1, naveen.n.rao
Cc: linux-riscv, linux-kernel
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 <chenguokai17@mails.ucas.ac.cn>.
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
@ 2022-05-23 1:51 ` Liao Chang
0 siblings, 0 replies; 6+ messages in thread
From: Liao Chang @ 2022-05-23 1:51 UTC (permalink / raw)
To: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz, jszhang,
liaochang1, naveen.n.rao
Cc: linux-riscv, linux-kernel
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 <chenguokai17@mails.ucas.ac.cn>.
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
2022-05-23 1:51 ` Liao Chang
@ 2022-05-24 15:12 ` Jisheng Zhang
-1 siblings, 0 replies; 6+ messages in thread
From: Jisheng Zhang @ 2022-05-24 15:12 UTC (permalink / raw)
To: Liao Chang, Guo Ren
Cc: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz,
naveen.n.rao, linux-riscv, linux-kernel
On Mon, May 23, 2022 at 09:51:24AM +0800, Liao Chang 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.
+ Guo Ren
Nice catch! I think csky needs the fix as well.
>
> This bug reported by Chen Guokai <chenguokai17@mails.ucas.ac.cn>.
This needs a "Reported-by: ..." tag
>
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
> 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
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
@ 2022-05-24 15:12 ` Jisheng Zhang
0 siblings, 0 replies; 6+ messages in thread
From: Jisheng Zhang @ 2022-05-24 15:12 UTC (permalink / raw)
To: Liao Chang, Guo Ren
Cc: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz,
naveen.n.rao, linux-riscv, linux-kernel
On Mon, May 23, 2022 at 09:51:24AM +0800, Liao Chang 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.
+ Guo Ren
Nice catch! I think csky needs the fix as well.
>
> This bug reported by Chen Guokai <chenguokai17@mails.ucas.ac.cn>.
This needs a "Reported-by: ..." tag
>
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
> 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
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
2022-05-24 15:12 ` Jisheng Zhang
@ 2022-05-25 1:24 ` liaochang (A)
-1 siblings, 0 replies; 6+ messages in thread
From: liaochang (A) @ 2022-05-25 1:24 UTC (permalink / raw)
To: Jisheng Zhang, Guo Ren
Cc: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz,
naveen.n.rao, linux-riscv, linux-kernel
在 2022/5/24 23:12, Jisheng Zhang 写道:
> On Mon, May 23, 2022 at 09:51:24AM +0800, Liao Chang 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.
>
> + Guo Ren
>
> Nice catch! I think csky needs the fix as well.
>
>>
>> This bug reported by Chen Guokai <chenguokai17@mails.ucas.ac.cn>.
>
> This needs a "Reported-by: ..." tag
Thanks for comment.
>
>>
>> Signed-off-by: Liao Chang <liaochang1@huawei.com>
>> ---
>> 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
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> .
--
BR,
Liao, Chang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration
@ 2022-05-25 1:24 ` liaochang (A)
0 siblings, 0 replies; 6+ messages in thread
From: liaochang (A) @ 2022-05-25 1:24 UTC (permalink / raw)
To: Jisheng Zhang, Guo Ren
Cc: paul.walmsley, palmer, aou, mhiramat, rostedt, peterz,
naveen.n.rao, linux-riscv, linux-kernel
在 2022/5/24 23:12, Jisheng Zhang 写道:
> On Mon, May 23, 2022 at 09:51:24AM +0800, Liao Chang 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.
>
> + Guo Ren
>
> Nice catch! I think csky needs the fix as well.
>
>>
>> This bug reported by Chen Guokai <chenguokai17@mails.ucas.ac.cn>.
>
> This needs a "Reported-by: ..." tag
Thanks for comment.
>
>>
>> Signed-off-by: Liao Chang <liaochang1@huawei.com>
>> ---
>> 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
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> .
--
BR,
Liao, Chang
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-25 1:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 1:51 [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration Liao Chang
2022-05-23 1:51 ` Liao Chang
2022-05-24 15:12 ` Jisheng Zhang
2022-05-24 15:12 ` Jisheng Zhang
2022-05-25 1:24 ` liaochang (A)
2022-05-25 1:24 ` liaochang (A)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.