Commit c55f8aaf authored by Dave Martin's avatar Dave Martin Committed by Greg Kroah-Hartman

arm64/ptrace: Reject attempts to set incomplete hardware breakpoint fields

commit ad9e202a upstream.

We cannot preserve partial fields for hardware breakpoints, because
the values written by userspace to the hardware breakpoint
registers can't subsequently be recovered intact from the hardware.

So, just reject attempts to write incomplete fields with -EINVAL.

Fixes: 478fcb2c ("arm64: Debugging support")
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Acked-by: default avatarWill Deacon <Will.Deacon@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4c87fc7f
...@@ -450,6 +450,8 @@ static int hw_break_set(struct task_struct *target, ...@@ -450,6 +450,8 @@ static int hw_break_set(struct task_struct *target,
/* (address, ctrl) registers */ /* (address, ctrl) registers */
limit = regset->n * regset->size; limit = regset->n * regset->size;
while (count && offset < limit) { while (count && offset < limit) {
if (count < PTRACE_HBP_ADDR_SZ)
return -EINVAL;
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr, ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
offset, offset + PTRACE_HBP_ADDR_SZ); offset, offset + PTRACE_HBP_ADDR_SZ);
if (ret) if (ret)
...@@ -459,6 +461,8 @@ static int hw_break_set(struct task_struct *target, ...@@ -459,6 +461,8 @@ static int hw_break_set(struct task_struct *target,
return ret; return ret;
offset += PTRACE_HBP_ADDR_SZ; offset += PTRACE_HBP_ADDR_SZ;
if (!count)
break;
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl,
offset, offset + PTRACE_HBP_CTRL_SZ); offset, offset + PTRACE_HBP_CTRL_SZ);
if (ret) if (ret)
......
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