]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
mips/ptrace: Preserve previous registers for short regset write
authorDave Martin <Dave.Martin@arm.com>
Mon, 27 Mar 2017 14:10:58 +0000 (15:10 +0100)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 3 Apr 2017 09:05:51 +0000 (10:05 +0100)
BugLink: http://bugs.launchpad.net/bugs/1678930
commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
arch/mips/kernel/ptrace.c

index c8ba2607213298ab0e4a846ca0fa26ee908b253e..5d2498eb2340c5681ebcaf522ffb3953a0e14a8f 100644 (file)
@@ -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));