mirror of https://gitee.com/openkylin/linux.git
powerpc/ptrace: Preserve previous fprs/vsrs on 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.
Fixes: c6e6771b87
("powerpc: Introduce VSX thread_struct and CONFIG_VSX")
Cc: stable@vger.kernel.org # v2.6.27+
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
27593d72c4
commit
99dfe80a2a
|
@ -463,6 +463,10 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
|
||||||
|
|
||||||
flush_fp_to_thread(target);
|
flush_fp_to_thread(target);
|
||||||
|
|
||||||
|
for (i = 0; i < 32 ; i++)
|
||||||
|
buf[i] = target->thread.TS_FPR(i);
|
||||||
|
buf[32] = target->thread.fp_state.fpscr;
|
||||||
|
|
||||||
/* copy to local buffer then write that out */
|
/* copy to local buffer then write that out */
|
||||||
i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
|
i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
|
||||||
if (i)
|
if (i)
|
||||||
|
@ -672,6 +676,9 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,
|
||||||
flush_altivec_to_thread(target);
|
flush_altivec_to_thread(target);
|
||||||
flush_vsx_to_thread(target);
|
flush_vsx_to_thread(target);
|
||||||
|
|
||||||
|
for (i = 0; i < 32 ; i++)
|
||||||
|
buf[i] = target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
|
||||||
|
|
||||||
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
||||||
buf, 0, 32 * sizeof(double));
|
buf, 0, 32 * sizeof(double));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
|
Loading…
Reference in New Issue