Commit 8f34a1da authored by Will Deacon's avatar Will Deacon Committed by Catalin Marinas

arm64: ptrace: use HW_BREAKPOINT_EMPTY type for disabled breakpoints

If a debugger tries to zero a hardware debug control register, the
kernel will try to infer both the type and length of the breakpoint
in order to sanity-check against the requested regset type. This will
fail because the encoding will appear as a zero-length breakpoint.

This patch changes the control register setting so that disabled
breakpoints are treated as HW_BREAKPOINT_EMPTY and no further
sanity-checking is required.
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 7797d17c
...@@ -234,28 +234,33 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, ...@@ -234,28 +234,33 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
struct arch_hw_breakpoint_ctrl ctrl, struct arch_hw_breakpoint_ctrl ctrl,
struct perf_event_attr *attr) struct perf_event_attr *attr)
{ {
int err, len, type; int err, len, type, disabled = !ctrl.enabled;
err = arch_bp_generic_fields(ctrl, &len, &type); if (disabled) {
if (err) len = 0;
return err; type = HW_BREAKPOINT_EMPTY;
} else {
switch (note_type) { err = arch_bp_generic_fields(ctrl, &len, &type);
case NT_ARM_HW_BREAK: if (err)
if ((type & HW_BREAKPOINT_X) != type) return err;
return -EINVAL;
break; switch (note_type) {
case NT_ARM_HW_WATCH: case NT_ARM_HW_BREAK:
if ((type & HW_BREAKPOINT_RW) != type) if ((type & HW_BREAKPOINT_X) != type)
return -EINVAL;
break;
case NT_ARM_HW_WATCH:
if ((type & HW_BREAKPOINT_RW) != type)
return -EINVAL;
break;
default:
return -EINVAL; return -EINVAL;
break; }
default:
return -EINVAL;
} }
attr->bp_len = len; attr->bp_len = len;
attr->bp_type = type; attr->bp_type = type;
attr->disabled = !ctrl.enabled; attr->disabled = disabled;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment