public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: "Rob Herring (Arm)" <robh@kernel•org>
To: Will Deacon <will@kernel•org>,
	Mark Rutland <mark.rutland@arm•com>,
	 Catalin Marinas <catalin.marinas@arm•com>,
	Jonathan Corbet <corbet@lwn•net>,
	 Shuah Khan <skhan@linuxfoundation•org>
Cc: Anshuman Khandual <anshuman.khandual@arm•com>,
	 linux-arm-kernel@lists•infradead.org,
	linux-perf-users@vger•kernel.org,  linux-kernel@vger•kernel.org,
	linux-doc@vger•kernel.org
Subject: [PATCH v4 1/6] arm64: hw_breakpoint: Disallow breakpoints in no kprobe code
Date: Tue, 07 Apr 2026 09:29:43 -0500	[thread overview]
Message-ID: <20260407-arm-debug-8-9-v4-1-a4864e69b0ea@kernel.org> (raw)
In-Reply-To: <20260407-arm-debug-8-9-v4-0-a4864e69b0ea@kernel.org>

Taking debug exceptions while manipulating the breakpoints is likely to
be unsafe. The setting kprobes in the breakpoint code is already
forbidden, but the setting of h/w breakpoints is not. Copy what x86 does
and exclude breakpoints that fall within the kprobe section.

Signed-off-by: Rob Herring (Arm) <robh@kernel•org>
---
 arch/arm64/kernel/hw_breakpoint.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index ab76b36dce82..38fbd67b2a6e 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -418,6 +418,16 @@ static int arch_build_bp_info(struct perf_event *bp,
 	/* Type */
 	switch (attr->bp_type) {
 	case HW_BREAKPOINT_X:
+		/*
+		 * We don't allow kernel breakpoints in places that are not
+		 * acceptable for kprobes.  On non-kprobes kernels, we don't
+		 * allow kernel breakpoints at all.
+		 */
+		if (attr->bp_addr >= TASK_SIZE_MAX) {
+			if (within_kprobe_blacklist(attr->bp_addr))
+				return -EINVAL;
+		}
+
 		hw->ctrl.type = ARM_BREAKPOINT_EXECUTE;
 		break;
 	case HW_BREAKPOINT_R:

-- 
2.53.0



  reply	other threads:[~2026-04-07 14:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 14:29 [PATCH v4 0/6] arm64: Add support for FEAT_Debugv8p9 Rob Herring (Arm)
2026-04-07 14:29 ` Rob Herring (Arm) [this message]
2026-05-28 10:57   ` [PATCH v4 1/6] arm64: hw_breakpoint: Disallow breakpoints in no kprobe code Will Deacon
2026-04-07 14:29 ` [PATCH v4 2/6] arm64: hw_breakpoint: Add additional kprobe excluded functions Rob Herring (Arm)
2026-04-07 14:29 ` [PATCH v4 3/6] arm64: hw_breakpoint: Add lockdep_assert_irqs_disabled() on install/uninstall Rob Herring (Arm)
2026-05-28 10:57   ` Will Deacon
2026-04-07 14:29 ` [PATCH v4 4/6] arm64/cpufeature: Add field details for ID_AA64DFR1_EL1 register Rob Herring (Arm)
2026-05-28 10:57   ` Will Deacon
2026-04-07 14:29 ` [PATCH v4 5/6] arm64/boot: Enable EL2 requirements for FEAT_Debugv8p9 Rob Herring (Arm)
2026-05-28 10:58   ` Will Deacon
2026-04-07 14:29 ` [PATCH v4 6/6] arm64: hw_breakpoint: Enable FEAT_Debugv8p9 Rob Herring (Arm)
2026-05-28 11:05   ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260407-arm-debug-8-9-v4-1-a4864e69b0ea@kernel.org \
    --to=robh@kernel$(echo .)org \
    --cc=anshuman.khandual@arm$(echo .)com \
    --cc=catalin.marinas@arm$(echo .)com \
    --cc=corbet@lwn$(echo .)net \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-doc@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-perf-users@vger$(echo .)kernel.org \
    --cc=mark.rutland@arm$(echo .)com \
    --cc=skhan@linuxfoundation$(echo .)org \
    --cc=will@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox