diff options
author | Will Deacon <will.deacon@arm.com> | 2013-12-17 12:09:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-09 15:24:20 -0500 |
commit | 11b81802921618b02122855db021a63df7d9fd49 (patch) | |
tree | 2a90082206760ac2d901ea31fa91438c9e077fa5 /arch/arm64 | |
parent | 885154cee87db097b01ae35d9ae9ee5feabeb9d7 (diff) |
arm64: ptrace: avoid using HW_BREAKPOINT_EMPTY for disabled events
commit cdc27c27843248ae7eb0df5fc261dd004eaa5670 upstream.
Commit 8f34a1da35ae ("arm64: ptrace: use HW_BREAKPOINT_EMPTY type for
disabled breakpoints") fixed an issue with GDB trying to zero breakpoint
control registers. The problem there is that the arch hw_breakpoint code
will attempt to create a (disabled), execute breakpoint of length 0.
This will fail validation and report unexpected failure to GDB. To avoid
this, we treated disabled breakpoints as HW_BREAKPOINT_EMPTY, but that
seems to have broken with recent kernels, causing watchpoints to be
treated as TYPE_INST in the core code and returning ENOSPC for any
further breakpoints.
This patch fixes the problem by prioritising the `enable' field of the
breakpoint: if it is cleared, we simply update the perf_event_attr to
indicate that the thing is disabled and don't bother changing either the
type or the length. This reinforces the behaviour that the breakpoint
control register is essentially read-only apart from the enable bit
when disabling a breakpoint.
Reported-by: Aaron Liu <liucy214@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/kernel/ptrace.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 6e1e77f1831c..5341534b6d04 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c | |||
@@ -236,31 +236,29 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, | |||
236 | { | 236 | { |
237 | int err, len, type, disabled = !ctrl.enabled; | 237 | int err, len, type, disabled = !ctrl.enabled; |
238 | 238 | ||
239 | if (disabled) { | 239 | attr->disabled = disabled; |
240 | len = 0; | 240 | if (disabled) |
241 | type = HW_BREAKPOINT_EMPTY; | 241 | return 0; |
242 | } else { | 242 | |
243 | err = arch_bp_generic_fields(ctrl, &len, &type); | 243 | err = arch_bp_generic_fields(ctrl, &len, &type); |
244 | if (err) | 244 | if (err) |
245 | return err; | 245 | return err; |
246 | 246 | ||
247 | switch (note_type) { | 247 | switch (note_type) { |
248 | case NT_ARM_HW_BREAK: | 248 | case NT_ARM_HW_BREAK: |
249 | if ((type & HW_BREAKPOINT_X) != type) | 249 | if ((type & HW_BREAKPOINT_X) != type) |
250 | return -EINVAL; | ||
251 | break; | ||
252 | case NT_ARM_HW_WATCH: | ||
253 | if ((type & HW_BREAKPOINT_RW) != type) | ||
254 | return -EINVAL; | ||
255 | break; | ||
256 | default: | ||
257 | return -EINVAL; | 250 | return -EINVAL; |
258 | } | 251 | break; |
252 | case NT_ARM_HW_WATCH: | ||
253 | if ((type & HW_BREAKPOINT_RW) != type) | ||
254 | return -EINVAL; | ||
255 | break; | ||
256 | default: | ||
257 | return -EINVAL; | ||
259 | } | 258 | } |
260 | 259 | ||
261 | attr->bp_len = len; | 260 | attr->bp_len = len; |
262 | attr->bp_type = type; | 261 | attr->bp_type = type; |
263 | attr->disabled = disabled; | ||
264 | 262 | ||
265 | return 0; | 263 | return 0; |
266 | } | 264 | } |