]> git.itanic.dy.fi Git - linux-stable/commitdiff
kprobe: reverse kp->flags when arm_kprobe failed
authorLi Qiang <liq3ea@163.com>
Thu, 3 Nov 2022 23:49:31 +0000 (08:49 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 16:46:54 +0000 (17:46 +0100)
commit 4a6f316d6855a434f56dbbeba05e14c01acde8f8 upstream.

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.

Link: https://lore.kernel.org/all/20220902155820.34755-1-liq3ea@163.com/
Fixes: 12310e343755 ("kprobes: Propagate error from arm_kprobe_ftrace()")
Cc: stable@vger.kernel.org
Signed-off-by: Li Qiang <liq3ea@163.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/kprobes.c

index b2f01e61f0eecb6c0b01f34ab14b7df3ea2e477a..33aba4e2e3e3932c0dac30fa47c2c3c122c059d1 100644 (file)
@@ -2172,8 +2172,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);