x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
authorBorislav Petkov <bp@suse.de>
Sun, 27 Jan 2019 13:03:57 +0000 (14:03 +0100)
committerBorislav Petkov <bp@suse.de>
Wed, 30 Jan 2019 10:52:21 +0000 (11:52 +0100)
Remove the ifdeffery in the breakpoint parsing arch_build_bp_info() by
adding a within_kprobe_blacklist() stub for the !CONFIG_KPROBES case.

It is returning true when kprobes are not enabled to mean that any
address is within the kprobes blacklist on such kernels and thus not
allow kernel breakpoints on non-kprobes kernels.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190127131237.4557-1-bp@alien8.de
arch/x86/kernel/hw_breakpoint.c
include/linux/kprobes.h

index 7d6f91f2869abf5ddc3dc21fc06e946929f54ead..ff9bfd40429efeb7b4868d370628356e28265ec1 100644 (file)
@@ -261,12 +261,8 @@ static int arch_build_bp_info(struct perf_event *bp,
                 * allow kernel breakpoints at all.
                 */
                if (attr->bp_addr >= TASK_SIZE_MAX) {
-#ifdef CONFIG_KPROBES
                        if (within_kprobe_blacklist(attr->bp_addr))
                                return -EINVAL;
-#else
-                       return -EINVAL;
-#endif
                }
 
                hw->type = X86_BREAKPOINT_EXECUTE;
index e07e91daaacc5c8d476ebe010d37ec6513bb648a..201f0f2683f25bd382267042f9f7dbec8460f093 100644 (file)
@@ -442,6 +442,11 @@ static inline int enable_kprobe(struct kprobe *kp)
 {
        return -ENOSYS;
 }
+
+static inline bool within_kprobe_blacklist(unsigned long addr)
+{
+       return true;
+}
 #endif /* CONFIG_KPROBES */
 static inline int disable_kretprobe(struct kretprobe *rp)
 {