arm64: kprobes: Use arch_populate_kprobe_blacklist()
authorMasami Hiramatsu <mhiramat@kernel.org>
Tue, 12 Feb 2019 15:44:48 +0000 (00:44 +0900)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 19 Mar 2019 12:47:44 +0000 (12:47 +0000)
Use arch_populate_kprobe_blacklist() instead of
arch_within_kprobe_blacklist() so that we can see the full
blacklisted symbols under the debugfs.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
[catalin.marinas@arm.com: Add arch_populate_kprobe_blacklist() comment]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/probes/kprobes.c

index d6697930d075dd75cd427c3940b7571bc607ff54..7a679caf45856e75c21860aaa7522c080fb48e41 100644 (file)
@@ -471,26 +471,37 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
        return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)
+/*
+ * Provide a blacklist of symbols identifying ranges which cannot be kprobed.
+ * This blacklist is exposed to userspace via debugfs (kprobes/blacklist).
+ */
+int __init arch_populate_kprobe_blacklist(void)
 {
-       if ((addr >= (unsigned long)__kprobes_text_start &&
-           addr < (unsigned long)__kprobes_text_end) ||
-           (addr >= (unsigned long)__entry_text_start &&
-           addr < (unsigned long)__entry_text_end) ||
-           (addr >= (unsigned long)__idmap_text_start &&
-           addr < (unsigned long)__idmap_text_end) ||
-           (addr >= (unsigned long)__hyp_text_start &&
-           addr < (unsigned long)__hyp_text_end) ||
-           in_exception_text(addr))
-               return true;
-
-       if (!is_kernel_in_hyp_mode()) {
-               if ((addr >= (unsigned long)__hyp_idmap_text_start &&
-                   addr < (unsigned long)__hyp_idmap_text_end))
-                       return true;
-       }
-
-       return false;
+       int ret;
+
+       ret = kprobe_add_area_blacklist((unsigned long)__entry_text_start,
+                                       (unsigned long)__entry_text_end);
+       if (ret)
+               return ret;
+       ret = kprobe_add_area_blacklist((unsigned long)__irqentry_text_start,
+                                       (unsigned long)__irqentry_text_end);
+       if (ret)
+               return ret;
+       ret = kprobe_add_area_blacklist((unsigned long)__exception_text_start,
+                                       (unsigned long)__exception_text_end);
+       if (ret)
+               return ret;
+       ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
+                                       (unsigned long)__idmap_text_end);
+       if (ret)
+               return ret;
+       ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
+                                       (unsigned long)__hyp_text_end);
+       if (ret || is_kernel_in_hyp_mode())
+               return ret;
+       ret = kprobe_add_area_blacklist((unsigned long)__hyp_idmap_text_start,
+                                       (unsigned long)__hyp_idmap_text_end);
+       return ret;
 }
 
 void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)