From 604016f19c7c54949e2f8df05d4de95e2fa2ff60 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 20 Dec 2007 03:57:34 -0800 Subject: [PATCH] --- yaml --- r: 83991 b: refs/heads/master c: f65255e8d51ecbc6c9eef20d39e0377d19b658ca h: refs/heads/master i: 83989: bf0bc89e8cd810ddf06d5409502a7239fc9bf8e3 83987: 2e4d58f957e32df3b4ea8c3f7c0f0d76bdef5f6d 83983: eda8ddf80321cb426a9dac5fe65473477fa95f87 v: v3 --- [refs] | 2 +- trunk/arch/powerpc/kernel/ptrace.c | 37 +++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 2c6a61e54e64..e31b477e1009 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5ab3e84f66321579ca36b63a13bf78decba65121 +refs/heads/master: f65255e8d51ecbc6c9eef20d39e0377d19b658ca diff --git a/trunk/arch/powerpc/kernel/ptrace.c b/trunk/arch/powerpc/kernel/ptrace.c index 8b056d2295cc..f1ce64649256 100644 --- a/trunk/arch/powerpc/kernel/ptrace.c +++ b/trunk/arch/powerpc/kernel/ptrace.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -103,24 +104,48 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data) } +static int fpr_get(struct task_struct *target, const struct user_regset *regset, + unsigned int pos, unsigned int count, + void *kbuf, void __user *ubuf) +{ + flush_fp_to_thread(target); + + BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != + offsetof(struct thread_struct, fpr[32])); + + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &target->thread.fpr, 0, -1); +} + +static int fpr_set(struct task_struct *target, const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + flush_fp_to_thread(target); + + BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != + offsetof(struct thread_struct, fpr[32])); + + return user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.fpr, 0, -1); +} + static int get_fpregs(void __user *data, struct task_struct *task, int has_fpscr) { unsigned int count = has_fpscr ? 33 : 32; - - if (copy_to_user(data, task->thread.fpr, count * sizeof(double))) + if (!access_ok(VERIFY_WRITE, data, count * sizeof(double))) return -EFAULT; - return 0; + return fpr_get(task, NULL, 0, count * sizeof(double), NULL, data); } static int set_fpregs(void __user *data, struct task_struct *task, int has_fpscr) { unsigned int count = has_fpscr ? 33 : 32; - - if (copy_from_user(task->thread.fpr, data, count * sizeof(double))) + if (!access_ok(VERIFY_READ, data, count * sizeof(double))) return -EFAULT; - return 0; + return fpr_set(task, NULL, 0, count * sizeof(double), NULL, data); }