From: Will Deacon <will@kernel.org>
To: Bill Tsui <b10902118@ntu.edu.tw>
Cc: oleg@redhat.com, catalin.marinas@arm.com, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, morbo@google.com,
justinstitt@google.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH v4 1/1] arm64: ptrace: fix hw_break_set() to set addr and ctrl together
Date: Fri, 14 Nov 2025 16:14:30 +0000 [thread overview]
Message-ID: <aRdVZmeOHYbm24NJ@willie-the-truck> (raw)
In-Reply-To: <20251018133731.42505-2-b10902118@ntu.edu.tw>
On Sat, Oct 18, 2025 at 09:37:31PM +0800, Bill Tsui wrote:
> This patch fixes the failure of PTRACE_SETREGSET when setting a hardware
> breakpoint on a non-4-byte aligned address with a valid control to a
> 32-bit tracee. The issue was discovered while testing LLDB.
>
> Link: https://github.com/llvm/llvm-project/pull/152284
>
> The failure happens because hw_break_set() checks and sets the breakpoint
> address and control separately. This can result in an check failure when
> it first validates the address to be set with old control.
>
> For example, the control are initialized with breakpoint length of 4.
> Combining with a non-4-byte aligned address would cross a 4-byte boundary,
> which is invalid. However, the user-provided control may actually specify a
> length of 1, which should be valid.
>
> The fix is to set the address and control together.
... but you only implement this for the native (64-bit) case, so I don't
understand how it helps with the problem above.
> For reference, the check is in
> arch/arm64/kernel/hw_breakpoint.c:hw_breakpoint_arch_parse()
> which is called via:
> modify_user_hw_breakpoint()
> -> modify_user_hw_breakpoint_check()
> -> hw_breakpoint_parse()
> -> hw_breakpoint_arch_parse()
You don't need to include these details here.
> @@ -524,9 +506,6 @@ static int hw_break_set(struct task_struct *target,
> return -EINVAL;
> ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
> offset, offset + PTRACE_HBP_ADDR_SZ);
> - if (ret)
> - return ret;
> - ret = ptrace_hbp_set_addr(note_type, target, idx, addr);
> if (ret)
> return ret;
> offset += PTRACE_HBP_ADDR_SZ;
> @@ -537,10 +516,11 @@ static int hw_break_set(struct task_struct *target,
> offset, offset + PTRACE_HBP_CTRL_SZ);
> if (ret)
> return ret;
> - ret = ptrace_hbp_set_ctrl(note_type, target, idx, ctrl);
> + offset += PTRACE_HBP_CTRL_SZ;
> +
> + ret = ptrace_hbp_set(note_type, target, idx, addr, ctrl);
Doesn't this break the case where userspace tries only to set the address?
The loop will break out when !count without updating anything.
As I mentioned before, I'd prefer to leave this code as-is short of
removing the indirection through perf entirely.
Will
next prev parent reply other threads:[~2025-11-14 16:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-24 12:43 [PATCH 0/3] ARM/arm64: ptrace: fix unaligned hardware breakpoint validation for 32bit b10902118
2025-08-24 12:43 ` [PATCH 1/3] arm64: ptrace: fix hw_break_set() by setting addr and ctrl together b10902118
2025-08-24 12:43 ` [PATCH 2/3] arm64: ptrace: minimize default bp_len for hw breakpoints to pass check b10902118
2025-08-24 12:43 ` [PATCH 3/3] ARM: " b10902118
2025-08-26 19:37 ` [PATCH 0/3] ARM/arm64: ptrace: fix unaligned hardware breakpoint validation for 32bit Catalin Marinas
2025-08-27 1:41 ` [PATCH v2 " Bill Tsui
2025-08-27 1:41 ` [PATCH v2 1/3] arm64: ptrace: fix hw_break_set() by setting addr and ctrl together Bill Tsui
2025-09-08 15:14 ` Will Deacon
2025-09-09 1:50 ` b10902118
2025-09-09 1:57 ` Bill Tsui
2025-09-17 14:23 ` Bill Tsui
2025-08-27 1:41 ` [PATCH v2 2/3] arm64: ptrace: minimize default bp_len for hw breakpoints to pass check Bill Tsui
2025-08-27 1:41 ` [PATCH v2 3/3] ARM: " Bill Tsui
2025-10-16 15:44 ` [PATCH v3 0/1] arm64: ptrace: fix hw_break_set() to set addr and ctrl together Bill Tsui
2025-10-16 15:44 ` [PATCH v3 1/1] " Bill Tsui
2025-10-18 8:24 ` kernel test robot
2025-10-18 13:37 ` [PATCH v4 0/1] " Bill Tsui
2025-10-18 13:37 ` [PATCH v4 1/1] " Bill Tsui
2025-11-14 16:14 ` Will Deacon [this message]
2025-11-15 3:44 ` Bill Tsui
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=aRdVZmeOHYbm24NJ@willie-the-truck \
--to=will@kernel.org \
--cc=b10902118@ntu.edu.tw \
--cc=catalin.marinas@arm.com \
--cc=justinstitt@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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