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

Commit 53b1a742 authored by Dave Martin's avatar Dave Martin Committed by Will Deacon
Browse files

arm64: ptrace: Avoid setting compat FP[SC]R to garbage if get_user fails



If get_user() fails when reading the new FPSCR value from userspace
in compat_vfp_get(), then garbage* will be written to the task's
FPSR and FPCR registers.

This patch prevents this by checking the return from get_user()
first.

[*] Actually, zero, due to the behaviour of get_user() on error, but
that's still not what userspace expects.

Fixes: 478fcb2c ("arm64: Debugging support")
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 15ad6ace
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -947,9 +947,11 @@ static int compat_vfp_set(struct task_struct *target,


	if (count && !ret) {
	if (count && !ret) {
		ret = get_user(fpscr, (compat_ulong_t *)ubuf);
		ret = get_user(fpscr, (compat_ulong_t *)ubuf);
		if (!ret) {
			uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK;
			uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK;
			uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
			uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
		}
		}
	}


	fpsimd_flush_task_state(target);
	fpsimd_flush_task_state(target);
	return ret;
	return ret;