From: Mikael Pettersson <mikpe@csd.uu.se>

- Add __user annotations on relevant system calls and helper functions.
- Swap cpus_copy_to_user() parameter order, to match copy_to_user().

Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/perfctr/init.c    |   12 ++++++------
 25-akpm/drivers/perfctr/virtual.c |   13 ++++++++-----
 25-akpm/include/linux/perfctr.h   |   11 +++++++----
 3 files changed, 21 insertions(+), 15 deletions(-)

diff -puN drivers/perfctr/init.c~perfctr-update-3-6-__user-annotations drivers/perfctr/init.c
--- 25/drivers/perfctr/init.c~perfctr-update-3-6-__user-annotations	2004-06-30 11:04:18.684092872 -0700
+++ 25-akpm/drivers/perfctr/init.c	2004-06-30 11:04:18.691091808 -0700
@@ -23,7 +23,7 @@ struct perfctr_info perfctr_info = {
 
 char *perfctr_cpu_name __initdata;
 
-static int cpus_copy_to_user(const cpumask_t *cpus, struct perfctr_cpu_mask *argp)
+static int cpus_copy_to_user(struct perfctr_cpu_mask __user *argp, const cpumask_t *cpus)
 {
 	const unsigned int k_nrwords = PERFCTR_CPUMASK_NRLONGS*(sizeof(long)/sizeof(int));
 	unsigned int u_nrwords;
@@ -47,21 +47,21 @@ static int cpus_copy_to_user(const cpuma
 	return 0;
 }
 
-asmlinkage long sys_perfctr_info(struct perfctr_info *infop,
-				 struct perfctr_cpu_mask *cpusp,
-				 struct perfctr_cpu_mask *forbiddenp)
+asmlinkage long sys_perfctr_info(struct perfctr_info __user *infop,
+				 struct perfctr_cpu_mask __user *cpusp,
+				 struct perfctr_cpu_mask __user *forbiddenp)
 {
 	if (infop && copy_to_user(infop, &perfctr_info, sizeof perfctr_info))
 		return -EFAULT;
 	if (cpusp) {
 		cpumask_t cpus = cpu_online_map;
-		int err = cpus_copy_to_user(&cpus, cpusp);
+		int err = cpus_copy_to_user(cpusp, &cpus);
 		if (err)
 			return err;
 	}
 	if (forbiddenp) {
 		cpumask_t cpus = perfctr_cpus_forbidden_mask;
-		int err = cpus_copy_to_user(&cpus, forbiddenp);
+		int err = cpus_copy_to_user(forbiddenp, &cpus);
 		if (err)
 			return err;
 	}
diff -puN drivers/perfctr/virtual.c~perfctr-update-3-6-__user-annotations drivers/perfctr/virtual.c
--- 25/drivers/perfctr/virtual.c~perfctr-update-3-6-__user-annotations	2004-06-30 11:04:18.685092720 -0700
+++ 25-akpm/drivers/perfctr/virtual.c	2004-06-30 11:04:18.692091656 -0700
@@ -391,7 +391,7 @@ void __vperfctr_set_cpus_allowed(struct 
  ****************************************************************/
 
 static int do_vperfctr_control(struct vperfctr *perfctr,
-			       const struct vperfctr_control *argp,
+			       const struct vperfctr_control __user *argp,
 			       struct task_struct *tsk)
 {
 	struct vperfctr_control control;
@@ -500,8 +500,8 @@ static int do_vperfctr_unlink(struct vpe
 }
 
 static int do_vperfctr_read(struct vperfctr *perfctr,
-			    struct perfctr_sum_ctrs *sump,
-			    struct vperfctr_control *controlp,
+			    struct perfctr_sum_ctrs __user *sump,
+			    struct vperfctr_control __user *controlp,
 			    const struct task_struct *tsk)
 {
 	struct perfctr_sum_ctrs sum;
@@ -840,7 +840,8 @@ static void vperfctr_put_tsk(struct task
 		put_task_struct(tsk);
 }
 
-asmlinkage long sys_vperfctr_control(int fd, const struct vperfctr_control *control)
+asmlinkage long sys_vperfctr_control(int fd,
+				     const struct vperfctr_control __user *control)
 {
 	struct vperfctr *perfctr;
 	struct task_struct *tsk;
@@ -903,7 +904,9 @@ asmlinkage long sys_vperfctr_iresume(int
 	return ret;
 }
 
-asmlinkage long sys_vperfctr_read(int fd, struct perfctr_sum_ctrs *sum, struct vperfctr_control *control)
+asmlinkage long sys_vperfctr_read(int fd,
+				  struct perfctr_sum_ctrs __user *sum,
+				  struct vperfctr_control __user *control)
 {
 	struct vperfctr *perfctr;
 	struct task_struct *tsk;
diff -puN include/linux/perfctr.h~perfctr-update-3-6-__user-annotations include/linux/perfctr.h
--- 25/include/linux/perfctr.h~perfctr-update-3-6-__user-annotations	2004-06-30 11:04:18.687092416 -0700
+++ 25-akpm/include/linux/perfctr.h	2004-06-30 11:04:18.692091656 -0700
@@ -66,14 +66,17 @@ struct vperfctr_control;
 /*
  * The perfctr system calls.
  */
-asmlinkage long sys_perfctr_info(struct perfctr_info*, struct perfctr_cpu_mask*, struct perfctr_cpu_mask*);
+asmlinkage long sys_perfctr_info(struct perfctr_info __user*,
+				 struct perfctr_cpu_mask __user*,
+				 struct perfctr_cpu_mask __user*);
 asmlinkage long sys_vperfctr_open(int tid, int creat);
-asmlinkage long sys_vperfctr_control(int fd, const struct vperfctr_control*);
+asmlinkage long sys_vperfctr_control(int fd,
+				     const struct vperfctr_control __user*);
 asmlinkage long sys_vperfctr_unlink(int fd);
 asmlinkage long sys_vperfctr_iresume(int fd);
 asmlinkage long sys_vperfctr_read(int fd,
-				  struct perfctr_sum_ctrs*,
-				  struct vperfctr_control*);
+				  struct perfctr_sum_ctrs __user*,
+				  struct vperfctr_control __user*);
 
 extern struct perfctr_info perfctr_info;
 
_