Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b34ca601 authored by Dave Martin's avatar Dave Martin Committed by Michael Ellerman
Browse files

powerpc/ptrace: Preserve previous TM fprs/vsrs on short regset write



Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
to fill all the check pointed registers, the thread's old check pointed
registers are preserved.

Fixes: 9d3918f7 ("powerpc/ptrace: Enable support for NT_PPC_CVSX")
Fixes: 19cbcbf7 ("powerpc/ptrace: Enable support for NT_PPC_CFPR")
Cc: stable@vger.kernel.org # v4.8+
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 99dfe80a
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -1026,6 +1026,10 @@ static int tm_cfpr_set(struct task_struct *target,
	flush_fp_to_thread(target);
	flush_fp_to_thread(target);
	flush_altivec_to_thread(target);
	flush_altivec_to_thread(target);


	for (i = 0; i < 32; i++)
		buf[i] = target->thread.TS_CKFPR(i);
	buf[32] = target->thread.ckfp_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)
@@ -1290,6 +1294,9 @@ static int tm_cvsx_set(struct task_struct *target,
	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.ckfp_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)