Commit e1d5a8fb authored by Dave Martin's avatar Dave Martin Committed by Will Deacon

arm64: ptrace: Flush FPSIMD regs back to thread_struct before reading

When reading the FPSIMD state of current (which occurs when dumping
core), it is possible that userspace has modified the FPSIMD
registers since the time the task was last scheduled out.  Such
changes are not guaranteed to be reflected immedately in
thread_struct.

As a result, a coredump can contain stale values for these
registers.  Reading the registers of a stopped task via ptrace is
unaffected.

This patch explicitly flushes the CPU state back to thread_struct
before dumping when operating on current, thus ensuring that
coredump contents are up to date.
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent af66b2d8
...@@ -623,6 +623,10 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset, ...@@ -623,6 +623,10 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
{ {
struct user_fpsimd_state *uregs; struct user_fpsimd_state *uregs;
uregs = &target->thread.fpsimd_state.user_fpsimd; uregs = &target->thread.fpsimd_state.user_fpsimd;
if (target == current)
fpsimd_preserve_current_state();
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1); return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1);
} }
...@@ -898,6 +902,9 @@ static int compat_vfp_get(struct task_struct *target, ...@@ -898,6 +902,9 @@ static int compat_vfp_get(struct task_struct *target,
uregs = &target->thread.fpsimd_state.user_fpsimd; uregs = &target->thread.fpsimd_state.user_fpsimd;
if (target == current)
fpsimd_preserve_current_state();
/* /*
* The VFP registers are packed into the fpsimd_state, so they all sit * The VFP registers are packed into the fpsimd_state, so they all sit
* nicely together for us. We just need to create the fpscr separately. * nicely together for us. We just need to create the fpscr separately.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment