summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDave Martin <Dave.Martin@arm.com>2017-03-27 15:10:58 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-29 08:54:17 -0700
commitd614fd58a2834cfe4efa472c33c8f3ce2338b09b (patch)
treedeec6900fdc5a75b61feafa6dd82e33af6318f51 /arch
parent7195ee3120d878259e8d94a5d9f808116f34d5ea (diff)
downloadlinux-0-day-d614fd58a2834cfe4efa472c33c8f3ce2338b09b.tar.gz
linux-0-day-d614fd58a2834cfe4efa472c33c8f3ce2338b09b.tar.xz
mips/ptrace: Preserve previous registers for short regset write
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved. Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/kernel/ptrace.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index c8ba260721329..5d2498eb2340c 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -485,7 +485,8 @@ static int fpr_set(struct task_struct *target,
&target->thread.fpu,
0, sizeof(elf_fpregset_t));
- for (i = 0; i < NUM_FPU_REGS; i++) {
+ BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t));
+ for (i = 0; i < NUM_FPU_REGS && count >= sizeof(elf_fpreg_t); i++) {
err = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&fpr_val, i * sizeof(elf_fpreg_t),
(i + 1) * sizeof(elf_fpreg_t));