Commit d053005f authored by Qi Hu's avatar Qi Hu Committed by Hongchen Zhang
Browse files

LoongArch: Fix missing fcsr in ptrace's fpr_set

mainline inclusion
from mainline-v5.19
commit b0f3bdc0
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB


CVE: NA

--------------------------------

In file ptrace.c, function fpr_set does not copy fcsr data from ubuf
to kbuf. That's the reason why fcsr cannot be modified by ptrace.

This patch fixs this problem and allows users using ptrace to modify
the fcsr.

Co-developed-by: default avatarXu Li <lixu@loongson.cn>
Signed-off-by: default avatarQi Hu <huqi@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent ba7ba3a8
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ static int fpr_set(struct task_struct *target,
		   const void *kbuf, const void __user *ubuf)
{
	const int fcc_start = NUM_FPU_REGS * sizeof(elf_fpreg_t);
	const int fcc_end = fcc_start + sizeof(u64);
	const int fcsr_start = fcc_start + sizeof(u64);
	int err;

	BUG_ON(count % sizeof(elf_fpreg_t));
@@ -209,10 +209,12 @@ static int fpr_set(struct task_struct *target,
	if (err)
		return err;

	if (count > 0)
	err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
					  &target->thread.fpu.fcc,
					  fcc_start, fcc_end);
				  &target->thread.fpu.fcc, fcc_start,
				  fcc_start + sizeof(u64));
	err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
				  &target->thread.fpu.fcsr, fcsr_start,
				  fcsr_start + sizeof(u32));

	return err;
}