* [PATCH] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
@ 2019-01-27 13:12 Borislav Petkov
2019-01-28 13:57 ` Masami Hiramatsu
2019-01-30 11:03 ` [tip:x86/cleanups] " tip-bot for Borislav Petkov
0 siblings, 2 replies; 3+ messages in thread
From: Borislav Petkov @ 2019-01-27 13:12 UTC (permalink / raw)
To: X86 ML
Cc: LKML, Anil S Keshavamurthy, David S. Miller, Frederic Weisbecker,
H. Peter Anvin, Ingo Molnar, Masami Hiramatsu, Naveen N. Rao,
Thomas Gleixner
From: Borislav Petkov <bp@suse.de>
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>
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: Masami Hiramatsu <mhiramat@kernel.org>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/hw_breakpoint.c | 4 ----
include/linux/kprobes.h | 5 +++++
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index 7d6f91f2869a..ff9bfd40429e 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -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;
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e07e91daaacc..201f0f2683f2 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -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)
{
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
2019-01-27 13:12 [PATCH] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery Borislav Petkov
@ 2019-01-28 13:57 ` Masami Hiramatsu
2019-01-30 11:03 ` [tip:x86/cleanups] " tip-bot for Borislav Petkov
1 sibling, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2019-01-28 13:57 UTC (permalink / raw)
To: Borislav Petkov
Cc: X86 ML, LKML, Anil S Keshavamurthy, David S. Miller,
Frederic Weisbecker, H. Peter Anvin, Ingo Molnar,
Masami Hiramatsu, Naveen N. Rao, Thomas Gleixner
On Sun, 27 Jan 2019 14:12:37 +0100
Borislav Petkov <bp@alien8.de> wrote:
> From: Borislav Petkov <bp@suse.de>
>
> 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.
>
This looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you Borislav!!
> Signed-off-by: Borislav Petkov <bp@suse.de>
> 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: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> ---
> arch/x86/kernel/hw_breakpoint.c | 4 ----
> include/linux/kprobes.h | 5 +++++
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
> index 7d6f91f2869a..ff9bfd40429e 100644
> --- a/arch/x86/kernel/hw_breakpoint.c
> +++ b/arch/x86/kernel/hw_breakpoint.c
> @@ -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;
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index e07e91daaacc..201f0f2683f2 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -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)
> {
> --
> 2.19.1
>
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:x86/cleanups] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery
2019-01-27 13:12 [PATCH] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery Borislav Petkov
2019-01-28 13:57 ` Masami Hiramatsu
@ 2019-01-30 11:03 ` tip-bot for Borislav Petkov
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Borislav Petkov @ 2019-01-30 11:03 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, mhiramat, tglx, bp, davem, naveen.n.rao, frederic, hpa,
anil.s.keshavamurthy, mingo, linux-kernel
Commit-ID: fab940755d1d78377901450b6ee7c77356e06821
Gitweb: https://git.kernel.org/tip/fab940755d1d78377901450b6ee7c77356e06821
Author: Borislav Petkov <bp@suse.de>
AuthorDate: Sun, 27 Jan 2019 14:03:57 +0100
Committer: Borislav Petkov <bp@suse.de>
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.
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 | 4 ----
include/linux/kprobes.h | 5 +++++
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index 7d6f91f2869a..ff9bfd40429e 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -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;
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e07e91daaacc..201f0f2683f2 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -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)
{
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-30 11:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 13:12 [PATCH] x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery Borislav Petkov
2019-01-28 13:57 ` Masami Hiramatsu
2019-01-30 11:03 ` [tip:x86/cleanups] " tip-bot for Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).