Patch "kprobes: Fix check for probe enabled in kill_kprobe()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kprobes: Fix check for probe enabled in kill_kprobe()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kprobes-fix-check-for-probe-enabled-in-kill_kprobe.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 616b15eb61bd68a4105f970a3b0af031638d22e1
Author: Li Huafei <lihuafei1@xxxxxxxxxx>
Date:   Sat Nov 26 19:43:16 2022 +0800

    kprobes: Fix check for probe enabled in kill_kprobe()
    
    [ Upstream commit 0c76ef3f26d5ef2ac2c21b47e7620cff35809fbb ]
    
    In kill_kprobe(), the check whether disarm_kprobe_ftrace() needs to be
    called always fails. This is because before that we set the
    KPROBE_FLAG_GONE flag for kprobe so that "!kprobe_disabled(p)" is always
    false.
    
    The disarm_kprobe_ftrace() call introduced by commit:
    
      0cb2f1372baa ("kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler")
    
    to fix the NULL pointer reference problem. When the probe is enabled, if
    we do not disarm it, this problem still exists.
    
    Fix it by putting the probe enabled check before setting the
    KPROBE_FLAG_GONE flag.
    
    Link: https://lore.kernel.org/all/20221126114316.201857-1-lihuafei1@xxxxxxxxxx/
    
    Fixes: 3031313eb3d54 ("kprobes: Fix to check probe enabled before disarm_kprobe_ftrace()")
    Signed-off-by: Li Huafei <lihuafei1@xxxxxxxxxx>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
    Reviewed-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 6d2a8623ec7b..771fcce54fac 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2360,6 +2360,14 @@ static void kill_kprobe(struct kprobe *p)
 
 	lockdep_assert_held(&kprobe_mutex);
 
+	/*
+	 * The module is going away. We should disarm the kprobe which
+	 * is using ftrace, because ftrace framework is still available at
+	 * 'MODULE_STATE_GOING' notification.
+	 */
+	if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed)
+		disarm_kprobe_ftrace(p);
+
 	p->flags |= KPROBE_FLAG_GONE;
 	if (kprobe_aggrprobe(p)) {
 		/*
@@ -2376,14 +2384,6 @@ static void kill_kprobe(struct kprobe *p)
 	 * the original probed function (which will be freed soon) any more.
 	 */
 	arch_remove_kprobe(p);
-
-	/*
-	 * The module is going away. We should disarm the kprobe which
-	 * is using ftrace, because ftrace framework is still available at
-	 * 'MODULE_STATE_GOING' notification.
-	 */
-	if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed)
-		disarm_kprobe_ftrace(p);
 }
 
 /* Disable one kprobe */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux