Re: [syzbot] [hardening?] [mm?] BUG: bad usercopy in fpa_set

From: Tetsuo Handa
Date: Tue Mar 05 2024 - 05:32:33 EST


#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index c421a899fc84..29b28961637c 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -573,8 +573,10 @@ static int fpa_get(struct task_struct *target,
const struct user_regset *regset,
struct membuf to)
{
- return membuf_write(&to, &task_thread_info(target)->fpstate,
- sizeof(struct user_fp));
+ struct thread_info *thread = task_thread_info(target);
+
+ return membuf_write(&to, &thread->fpstate,
+ sizeof(thread->fpstate));
}

static int fpa_set(struct task_struct *target,
@@ -586,7 +588,7 @@ static int fpa_set(struct task_struct *target,

return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&thread->fpstate,
- 0, sizeof(struct user_fp));
+ 0, sizeof(thread->fpstate));
}

#ifdef CONFIG_VFP