Skip to contentSkip to conversation

Patch "arm64/ptrace: Reject attempts to set incomplete hardware breakpoint fields" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Jan 23, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

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

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
arm64-ptrace-reject-attempts-to-set-incomplete-hardware-breakpoint-fields.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From ad9e202aa1ce571b1d7fed969d06f66067f8a086 Mon Sep 17 00:00:00 2001

From: Dave Martin <[email protected]>
Date: Wed, 18 Jan 2017 16:25:24 +0000
Subject: arm64/ptrace: Reject attempts to set incomplete hardware breakpoint fields

From: Dave Martin <[email protected]>

commit ad9e202aa1ce571b1d7fed969d06f66067f8a086 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 478fcb2cdb23 ("arm64: Debugging support")
---
 arch/arm64/kernel/ptrace.c |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/kernel/ptrace.c +4 -0
@@ -550,6 +550,8 @@ static int hw_break_set(struct task_stru
 	/* (address, ctrl) registers */
 	limit = regset->n * regset->size;
 	while (count && offset < limit) {
+		if (count < PTRACE_HBP_ADDR_SZ)
+			return -EINVAL;
 		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
 					 offset, offset + PTRACE_HBP_ADDR_SZ);
 		if (ret)
@@ -559,6 +561,8 @@ static int hw_break_set(struct task_stru
 			return ret;
 		offset += PTRACE_HBP_ADDR_SZ;
 
+		if (!count)
+			break;
 		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl,
 					 offset, offset + PTRACE_HBP_CTRL_SZ);
 		if (ret)

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/arm64-ptrace-preserve-previous-registers-for-short-regset-write-3.patch queue-4.9/arm64-ptrace-reject-attempts-to-set-incomplete-hardware-breakpoint-fields.patch queue-4.9/powerpc-ptrace-preserve-previous-tm-fprs-vsrs-on-short-regset-write.patch queue-4.9/arm64-ptrace-preserve-previous-registers-for-short-regset-write-2.patch queue-4.9/arm64-ptrace-avoid-uninitialised-struct-padding-in-fpr_set.patch queue-4.9/arm64-ptrace-preserve-previous-registers-for-short-regset-write.patch queue-4.9/powerpc-ptrace-preserve-previous-fprs-vsrs-on-short-regset-write.patch