x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
Borislav Petkov
maintainerPATCH 1/1 x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
From: Borislav Petkov <[email protected]>
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.
--- arch/x86/kernel/hw_breakpoint.c | 4 ---- include/linux/kprobes.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/kernel/hw_breakpoint.c +0 -4
@@ -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 ;
include/linux/kprobes.h +5 -0
@@ -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) {
Signature · 1 line
2.19.1
Quoted 9 lines · On Sun, 27 Jan 2019 14:12:37 +0100 Borislav Petkov <[email protected]> wrote:
From: Borislav Petkov <[email protected]>
Remove the ifdeffery in the breakpoint parsing
arch_build_bp_info()by adding awithin_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.
This looks good to me.
Thank you Borislav!!
Quoted 50 lines
Signed-off-by Borislav Petkov <[email protected]>Cc Anil S Keshavamurthy <[email protected]>Cc "David S. Miller" <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Ingo Molnar <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc "Naveen N. Rao" <[email protected]>Cc Thomas Gleixner <[email protected]>--- arch/x86/kernel/hw_breakpoint.c | 4 ---- include/linux/kprobes.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-)arch/x86/kernel/hw_breakpoint.c +0
-4@@ -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 ;include/linux/kprobes.h +5
-0@@ -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) {Signature · 1 line
2.19.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
tip-bot for Borislav Petkov
merge botx86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
Commit-ID: fab940755d1d78377901450b6ee7c77356e06821 Gitweb: https://git.kernel.org/tip/fab940755d1d78377901450b6ee7c77356e06821 Author: Borislav Petkov <[email protected]> AuthorDate: Sun, 27 Jan 2019 14:03:57 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Wed, 30 Jan 2019 11:52:21 +0100
x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
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.
--- arch/x86/kernel/hw_breakpoint.c | 4 ---- include/linux/kprobes.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/kernel/hw_breakpoint.c +0 -4
@@ -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 ;
include/linux/kprobes.h +5 -0
@@ -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) {