aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/kernel/perfmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64/kernel/perfmon.c')
-rw-r--r--arch/ia64/kernel/perfmon.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 3fa4bc536953..f388b4e18a37 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2306,7 +2306,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2306 * partially initialize the vma for the sampling buffer 2306 * partially initialize the vma for the sampling buffer
2307 */ 2307 */
2308 vma->vm_mm = mm; 2308 vma->vm_mm = mm;
2309 vma->vm_file = filp; 2309 vma->vm_file = get_file(filp);
2310 vma->vm_flags = VM_READ| VM_MAYREAD |VM_RESERVED; 2310 vma->vm_flags = VM_READ| VM_MAYREAD |VM_RESERVED;
2311 vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */ 2311 vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */
2312 2312
@@ -2345,8 +2345,6 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2345 goto error; 2345 goto error;
2346 } 2346 }
2347 2347
2348 get_file(filp);
2349
2350 /* 2348 /*
2351 * now insert the vma in the vm list for the process, must be 2349 * now insert the vma in the vm list for the process, must be
2352 * done with mmap lock held 2350 * done with mmap lock held
@@ -2380,8 +2378,8 @@ static int
2380pfm_bad_permissions(struct task_struct *task) 2378pfm_bad_permissions(struct task_struct *task)
2381{ 2379{
2382 const struct cred *tcred; 2380 const struct cred *tcred;
2383 uid_t uid = current_uid(); 2381 kuid_t uid = current_uid();
2384 gid_t gid = current_gid(); 2382 kgid_t gid = current_gid();
2385 int ret; 2383 int ret;
2386 2384
2387 rcu_read_lock(); 2385 rcu_read_lock();
@@ -2389,20 +2387,20 @@ pfm_bad_permissions(struct task_struct *task)
2389 2387
2390 /* inspired by ptrace_attach() */ 2388 /* inspired by ptrace_attach() */
2391 DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n", 2389 DPRINT(("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n",
2392 uid, 2390 from_kuid(&init_user_ns, uid),
2393 gid, 2391 from_kgid(&init_user_ns, gid),
2394 tcred->euid, 2392 from_kuid(&init_user_ns, tcred->euid),
2395 tcred->suid, 2393 from_kuid(&init_user_ns, tcred->suid),
2396 tcred->uid, 2394 from_kuid(&init_user_ns, tcred->uid),
2397 tcred->egid, 2395 from_kgid(&init_user_ns, tcred->egid),
2398 tcred->sgid)); 2396 from_kgid(&init_user_ns, tcred->sgid)));
2399 2397
2400 ret = ((uid != tcred->euid) 2398 ret = ((!uid_eq(uid, tcred->euid))
2401 || (uid != tcred->suid) 2399 || (!uid_eq(uid, tcred->suid))
2402 || (uid != tcred->uid) 2400 || (!uid_eq(uid, tcred->uid))
2403 || (gid != tcred->egid) 2401 || (!gid_eq(gid, tcred->egid))
2404 || (gid != tcred->sgid) 2402 || (!gid_eq(gid, tcred->sgid))
2405 || (gid != tcred->gid)) && !capable(CAP_SYS_PTRACE); 2403 || (!gid_eq(gid, tcred->gid))) && !capable(CAP_SYS_PTRACE);
2406 2404
2407 rcu_read_unlock(); 2405 rcu_read_unlock();
2408 return ret; 2406 return ret;
@@ -4782,7 +4780,7 @@ recheck:
4782asmlinkage long 4780asmlinkage long
4783sys_perfmonctl (int fd, int cmd, void __user *arg, int count) 4781sys_perfmonctl (int fd, int cmd, void __user *arg, int count)
4784{ 4782{
4785 struct file *file = NULL; 4783 struct fd f = {NULL, 0};
4786 pfm_context_t *ctx = NULL; 4784 pfm_context_t *ctx = NULL;
4787 unsigned long flags = 0UL; 4785 unsigned long flags = 0UL;
4788 void *args_k = NULL; 4786 void *args_k = NULL;
@@ -4879,17 +4877,17 @@ restart_args:
4879 4877
4880 ret = -EBADF; 4878 ret = -EBADF;
4881 4879
4882 file = fget(fd); 4880 f = fdget(fd);
4883 if (unlikely(file == NULL)) { 4881 if (unlikely(f.file == NULL)) {
4884 DPRINT(("invalid fd %d\n", fd)); 4882 DPRINT(("invalid fd %d\n", fd));
4885 goto error_args; 4883 goto error_args;
4886 } 4884 }
4887 if (unlikely(PFM_IS_FILE(file) == 0)) { 4885 if (unlikely(PFM_IS_FILE(f.file) == 0)) {
4888 DPRINT(("fd %d not related to perfmon\n", fd)); 4886 DPRINT(("fd %d not related to perfmon\n", fd));
4889 goto error_args; 4887 goto error_args;
4890 } 4888 }
4891 4889
4892 ctx = file->private_data; 4890 ctx = f.file->private_data;
4893 if (unlikely(ctx == NULL)) { 4891 if (unlikely(ctx == NULL)) {
4894 DPRINT(("no context for fd %d\n", fd)); 4892 DPRINT(("no context for fd %d\n", fd));
4895 goto error_args; 4893 goto error_args;
@@ -4919,8 +4917,8 @@ abort_locked:
4919 if (call_made && PFM_CMD_RW_ARG(cmd) && copy_to_user(arg, args_k, base_sz*count)) ret = -EFAULT; 4917 if (call_made && PFM_CMD_RW_ARG(cmd) && copy_to_user(arg, args_k, base_sz*count)) ret = -EFAULT;
4920 4918
4921error_args: 4919error_args:
4922 if (file) 4920 if (f.file)
4923 fput(file); 4921 fdput(f);
4924 4922
4925 kfree(args_k); 4923 kfree(args_k);
4926 4924