[PATCH] kprobes: Disable lockdep for kprobe busy area

From: Masami Hiramatsu
Date: Mon Nov 02 2020 - 01:37:28 EST


Since the code area in between kprobe_busy_begin()/end() prohibits
other kprobs to call probe handlers, we can avoid inconsitent
locks there. But lockdep doesn't know that, so it warns rp->lock
or kretprobe_table_lock.

To supress those false-positive errors, disable lockdep while
kprobe_busy is set.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
kernel/kprobes.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 8a12a25fa40d..c7196e583600 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1295,10 +1295,12 @@ void kprobe_busy_begin(void)
__this_cpu_write(current_kprobe, &kprobe_busy);
kcb = get_kprobe_ctlblk();
kcb->kprobe_status = KPROBE_HIT_ACTIVE;
+ lockdep_off();
}

void kprobe_busy_end(void)
{
+ lockdep_on();
__this_cpu_write(current_kprobe, NULL);
preempt_enable();
}
--
2.25.1


--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>