提交 9dce990d 编写于 作者: M Martin Schwidefsky

s390/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.

convert_vx_to_fp() is adapted to handle only a specified number of
registers rather than unconditionally handling all of them: other
callers of this function are adapted appropriately.

Based on an initial patch by Dave Martin.

Cc: stable@vger.kernel.org
Reported-by: NDave Martin <Dave.Martin@arm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 a4685d2f
...@@ -963,6 +963,11 @@ static int s390_fpregs_set(struct task_struct *target, ...@@ -963,6 +963,11 @@ static int s390_fpregs_set(struct task_struct *target,
if (target == current) if (target == current)
save_fpu_regs(); save_fpu_regs();
if (MACHINE_HAS_VX)
convert_vx_to_fp(fprs, target->thread.fpu.vxrs);
else
memcpy(&fprs, target->thread.fpu.fprs, sizeof(fprs));
/* If setting FPC, must validate it first. */ /* If setting FPC, must validate it first. */
if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) { if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) {
u32 ufpc[2] = { target->thread.fpu.fpc, 0 }; u32 ufpc[2] = { target->thread.fpu.fpc, 0 };
...@@ -1067,6 +1072,9 @@ static int s390_vxrs_low_set(struct task_struct *target, ...@@ -1067,6 +1072,9 @@ static int s390_vxrs_low_set(struct task_struct *target,
if (target == current) if (target == current)
save_fpu_regs(); save_fpu_regs();
for (i = 0; i < __NUM_VXRS_LOW; i++)
vxrs[i] = *((__u64 *)(target->thread.fpu.vxrs + i) + 1);
rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1); rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1);
if (rc == 0) if (rc == 0)
for (i = 0; i < __NUM_VXRS_LOW; i++) for (i = 0; i < __NUM_VXRS_LOW; i++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册