Skip to content

Commit

Permalink
LoongArch: Fix missing fcsr in ptrace's fpr_set
Browse files Browse the repository at this point in the history
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: Xu Li <[email protected]>
Signed-off-by: Qi Hu <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
  • Loading branch information
specialpointcentral authored and chenhuacai committed Jul 29, 2022
1 parent 1aea29d commit b0f3bdc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions arch/loongarch/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&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;
}
Expand Down

0 comments on commit b0f3bdc

Please sign in to comment.