* [PATCH] kprobe: reverse kp->flags when arm_kprobe failed
@ 2022-09-02 15:58 Li Qiang
2022-09-08 4:51 ` Li Qiang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Li Qiang @ 2022-09-02 15:58 UTC (permalink / raw)
To: naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat
Cc: linux-kernel, liq3ea, Li Qiang
In aggregate kprobe case, when arm_kprobe failed,
we need set the kp->flags with KPROBE_FLAG_DISABLED again.
If not, the 'kp' kprobe will been considered as enabled
but it actually not enabled.
Signed-off-by: Li Qiang <liq3ea@163.com>
---
kernel/kprobes.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 08350e35a..333454df5 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp)
if (!kprobes_all_disarmed && kprobe_disabled(p)) {
p->flags &= ~KPROBE_FLAG_DISABLED;
ret = arm_kprobe(p);
- if (ret)
+ if (ret) {
p->flags |= KPROBE_FLAG_DISABLED;
+ if (p != kp)
+ kp->flags |= KPROBE_FLAG_DISABLED;
+ }
}
out:
mutex_unlock(&kprobe_mutex);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed
2022-09-02 15:58 [PATCH] kprobe: reverse kp->flags when arm_kprobe failed Li Qiang
@ 2022-09-08 4:51 ` Li Qiang
2022-09-09 13:07 ` Masami Hiramatsu
2022-09-27 2:07 ` Li Qiang
2 siblings, 0 replies; 5+ messages in thread
From: Li Qiang @ 2022-09-08 4:51 UTC (permalink / raw)
To: Li Qiang
Cc: naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat, linux-kernel
Kindly ping.
Li Qiang <liq3ea@163.com> 于2022年9月3日周六 00:00写道:
>
> In aggregate kprobe case, when arm_kprobe failed,
> we need set the kp->flags with KPROBE_FLAG_DISABLED again.
> If not, the 'kp' kprobe will been considered as enabled
> but it actually not enabled.
>
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> kernel/kprobes.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 08350e35a..333454df5 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp)
> if (!kprobes_all_disarmed && kprobe_disabled(p)) {
> p->flags &= ~KPROBE_FLAG_DISABLED;
> ret = arm_kprobe(p);
> - if (ret)
> + if (ret) {
> p->flags |= KPROBE_FLAG_DISABLED;
> + if (p != kp)
> + kp->flags |= KPROBE_FLAG_DISABLED;
> + }
> }
> out:
> mutex_unlock(&kprobe_mutex);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed
2022-09-02 15:58 [PATCH] kprobe: reverse kp->flags when arm_kprobe failed Li Qiang
2022-09-08 4:51 ` Li Qiang
@ 2022-09-09 13:07 ` Masami Hiramatsu
2022-09-15 7:04 ` Li Qiang
2022-09-27 2:07 ` Li Qiang
2 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2022-09-09 13:07 UTC (permalink / raw)
To: Li Qiang
Cc: naveen.n.rao, anil.s.keshavamurthy, davem, linux-kernel, liq3ea,
Steven Rostedt
On Fri, 2 Sep 2022 08:58:20 -0700
Li Qiang <liq3ea@163.com> wrote:
> In aggregate kprobe case, when arm_kprobe failed,
> we need set the kp->flags with KPROBE_FLAG_DISABLED again.
> If not, the 'kp' kprobe will been considered as enabled
> but it actually not enabled.
>
> Signed-off-by: Li Qiang <liq3ea@163.com>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks!
> ---
> kernel/kprobes.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 08350e35a..333454df5 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp)
> if (!kprobes_all_disarmed && kprobe_disabled(p)) {
> p->flags &= ~KPROBE_FLAG_DISABLED;
> ret = arm_kprobe(p);
> - if (ret)
> + if (ret) {
> p->flags |= KPROBE_FLAG_DISABLED;
> + if (p != kp)
> + kp->flags |= KPROBE_FLAG_DISABLED;
> + }
> }
> out:
> mutex_unlock(&kprobe_mutex);
> --
> 2.25.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed
2022-09-09 13:07 ` Masami Hiramatsu
@ 2022-09-15 7:04 ` Li Qiang
0 siblings, 0 replies; 5+ messages in thread
From: Li Qiang @ 2022-09-15 7:04 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: Li Qiang, naveen.n.rao, anil.s.keshavamurthy, davem,
linux-kernel, Steven Rostedt
Masami Hiramatsu <mhiramat@kernel.org> 于2022年9月9日周五 21:07写道:
>
> On Fri, 2 Sep 2022 08:58:20 -0700
> Li Qiang <liq3ea@163.com> wrote:
>
> > In aggregate kprobe case, when arm_kprobe failed,
> > we need set the kp->flags with KPROBE_FLAG_DISABLED again.
> > If not, the 'kp' kprobe will been considered as enabled
> > but it actually not enabled.
> >
> > Signed-off-by: Li Qiang <liq3ea@163.com>
>
> Looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Hello Masami,
Who should merge this, you? This issue will crash the kernel before:
0bc11ed5ab60c135aa764a62c02cd5ea68289de4 commit ("kprobes: Allow
kprobes coexist with
livepatch") and
8094029330a2f03fb406ecff80671cf27ce28d42 commit("libbpf: Cleanup the
legacy kprobe_event on failed add/attach_event()")
Thanks,
Li Qiang
>
> Thanks!
>
> > ---
> > kernel/kprobes.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 08350e35a..333454df5 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp)
> > if (!kprobes_all_disarmed && kprobe_disabled(p)) {
> > p->flags &= ~KPROBE_FLAG_DISABLED;
> > ret = arm_kprobe(p);
> > - if (ret)
> > + if (ret) {
> > p->flags |= KPROBE_FLAG_DISABLED;
> > + if (p != kp)
> > + kp->flags |= KPROBE_FLAG_DISABLED;
> > + }
> > }
> > out:
> > mutex_unlock(&kprobe_mutex);
> > --
> > 2.25.1
> >
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kprobe: reverse kp->flags when arm_kprobe failed
2022-09-02 15:58 [PATCH] kprobe: reverse kp->flags when arm_kprobe failed Li Qiang
2022-09-08 4:51 ` Li Qiang
2022-09-09 13:07 ` Masami Hiramatsu
@ 2022-09-27 2:07 ` Li Qiang
2 siblings, 0 replies; 5+ messages in thread
From: Li Qiang @ 2022-09-27 2:07 UTC (permalink / raw)
To: Li Qiang
Cc: naveen.n.rao, anil.s.keshavamurthy, davem, Masami Hiramatsu,
linux-kernel
Hello all,
What's the status of this patch?
Li Qiang <liq3ea@163.com> 于2022年9月3日周六 00:00写道:
>
> In aggregate kprobe case, when arm_kprobe failed,
> we need set the kp->flags with KPROBE_FLAG_DISABLED again.
> If not, the 'kp' kprobe will been considered as enabled
> but it actually not enabled.
>
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> kernel/kprobes.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 08350e35a..333454df5 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -2424,8 +2424,11 @@ int enable_kprobe(struct kprobe *kp)
> if (!kprobes_all_disarmed && kprobe_disabled(p)) {
> p->flags &= ~KPROBE_FLAG_DISABLED;
> ret = arm_kprobe(p);
> - if (ret)
> + if (ret) {
> p->flags |= KPROBE_FLAG_DISABLED;
> + if (p != kp)
> + kp->flags |= KPROBE_FLAG_DISABLED;
> + }
> }
> out:
> mutex_unlock(&kprobe_mutex);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-27 2:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 15:58 [PATCH] kprobe: reverse kp->flags when arm_kprobe failed Li Qiang
2022-09-08 4:51 ` Li Qiang
2022-09-09 13:07 ` Masami Hiramatsu
2022-09-15 7:04 ` Li Qiang
2022-09-27 2:07 ` Li Qiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).