lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 24 Apr 2009 17:10:49 -0700 (PDT)
From:	Roland McGrath <roland@...hat.com>
To:	Russell King <rmk@....linux.org.uk>
Cc:	Christoph Hellwig <hch@....de>, linux-kernel@...r.kernel.org
Subject: [PATCH 07/17] arm: user_regset: FPU regs

This converts PTRACE_GETFPREGS/PTRACE_SETFPREGS into user_regset form.
There should be no change in the ptrace behavior.

Signed-off-by: Roland McGrath <roland@...hat.com>
---
 arch/arm/kernel/ptrace.c |   48 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index fbb18e4..9e7aa04 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -589,21 +589,38 @@ static int gpr_set(struct task_struct *target,
 /*
  * Get the child FPU state.
  */
-static int ptrace_getfpregs(struct task_struct *tsk, void __user *ufp)
+static int user_fp_get(struct task_struct *target,
+		       const struct user_regset *regset,
+		       unsigned int pos, unsigned int count,
+		       void *kbuf, void __user *ubuf)
 {
-	return copy_to_user(ufp, &task_thread_info(tsk)->fpstate,
-			    sizeof(struct user_fp)) ? -EFAULT : 0;
+	return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+				   &task_thread_info(target)->fpstate,
+				   0, sizeof(struct user_fp));
+}
+
+/*
+ * Decide if the FPU state is interesting enough to look at or dump.
+ */
+static int user_fp_active(struct task_struct *target,
+			  const struct user_regset *regset)
+{
+	struct thread_info *thread = task_thread_info(target);
+	return (thread->used_cp[1] || thread->used_cp[2]) ? regset->n : 0;
 }
 
 /*
  * Set the child FPU state.
  */
-static int ptrace_setfpregs(struct task_struct *tsk, void __user *ufp)
+static int user_fp_set(struct task_struct *target,
+		       const struct user_regset *regset,
+		       unsigned int pos, unsigned int count,
+		       const void *kbuf, const void __user *ubuf)
 {
-	struct thread_info *thread = task_thread_info(tsk);
+	struct thread_info *thread = task_thread_info(target);
 	thread->used_cp[1] = thread->used_cp[2] = 1;
-	return copy_from_user(&thread->fpstate, ufp,
-			      sizeof(struct user_fp)) ? -EFAULT : 0;
+	return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+				  &thread->fpstate, 0, sizeof(struct user_fp));
 }
 
 #ifdef CONFIG_IWMMXT
@@ -720,6 +737,7 @@ static int ptrace_setvfpregs(struct task_struct *tsk, void __user *data)
  */
 enum {
 	REGSET_GPR,
+	REGSET_FP,
 };
 
 static const struct user_regset arm_regsets[] = {
@@ -728,6 +746,12 @@ static const struct user_regset arm_regsets[] = {
 		.size = sizeof(long), .align = sizeof(long),
 		.get = gpr_get, .set = gpr_set
 	},
+	[REGSET_FP] = {
+		.core_note_type = NT_PRFPREG,
+		.n = sizeof(struct user_fp) / sizeof(long),
+		.size = sizeof(long), .align = sizeof(long),
+		.active = user_fp_active, .get = user_fp_get, .set = user_fp_set
+	},
 };
 
 static const struct user_regset_view user_arm_view = {
@@ -790,12 +814,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 					     (const void __user *) data);
 
 	case PTRACE_GETFPREGS:
-		ret = ptrace_getfpregs(child, (void __user *)data);
-		break;
+		return copy_regset_to_user(child, &user_arm_view, REGSET_FP,
+					   0, sizeof(struct user_fp),
+					   (void __user *) data);
 
 	case PTRACE_SETFPREGS:
-		ret = ptrace_setfpregs(child, (void __user *)data);
-		break;
+		return copy_regset_from_user(child, &user_arm_view, REGSET_FP,
+					     0, sizeof(struct user_fp),
+					     (const void __user *) data);
 
 #ifdef CONFIG_IWMMXT
 	case PTRACE_GETWMMXREGS:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ