Patch "kprobes: Suppress the suspicious RCU warning on kprobes" has been added to the 5.7-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: Suppress the suspicious RCU warning on kprobes

to the 5.7-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-suppress-the-suspicious-rcu-warning-on-kprob.patch
and it can be found in the queue-5.7 subdirectory.

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



commit fc3fed502943dc7a693345301448af58cc661c08
Author: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Date:   Tue May 12 17:02:33 2020 +0900

    kprobes: Suppress the suspicious RCU warning on kprobes
    
    [ Upstream commit 6743ad432ec92e680cd0d9db86cb17b949cf5a43 ]
    
    Anders reported that the lockdep warns that suspicious
    RCU list usage in register_kprobe() (detected by
    CONFIG_PROVE_RCU_LIST.) This is because get_kprobe()
    access kprobe_table[] by hlist_for_each_entry_rcu()
    without rcu_read_lock.
    
    If we call get_kprobe() from the breakpoint handler context,
    it is run with preempt disabled, so this is not a problem.
    But in other cases, instead of rcu_read_lock(), we locks
    kprobe_mutex so that the kprobe_table[] is not updated.
    So, current code is safe, but still not good from the view
    point of RCU.
    
    Joel suggested that we can silent that warning by passing
    lockdep_is_held() to the last argument of
    hlist_for_each_entry_rcu().
    
    Add lockdep_is_held(&kprobe_mutex) at the end of the
    hlist_for_each_entry_rcu() to suppress the warning.
    
    Link: http://lkml.kernel.org/r/158927055350.27680.10261450713467997503.stgit@devnote2
    
    Reported-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
    Suggested-by: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>
    Reviewed-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
    Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 195ecb955fcc5..950a5cfd262ce 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -326,7 +326,8 @@ struct kprobe *get_kprobe(void *addr)
 	struct kprobe *p;
 
 	head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
-	hlist_for_each_entry_rcu(p, head, hlist) {
+	hlist_for_each_entry_rcu(p, head, hlist,
+				 lockdep_is_held(&kprobe_mutex)) {
 		if (p->addr == addr)
 			return p;
 	}



[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