public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.5.41 capget fix
@ 2002-10-10  0:15 Chris Wright
  2002-10-10 19:36 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Wright @ 2002-10-10  0:15 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

Linus,

Daniel Jacobowitz noticed that sys_capget is not behaving properly when
called with pid of 0.  It is supposed to return current capabilities,
not those of swapper.  Also cleaned up some duplicate code from a merge
error.  Patch is tested, please apply.

thanks,
-chris

--- 2.5.41/kernel/capability.c	Sun Sep 15 12:19:29 2002
+++ 2.5.41-capget/kernel/capability.c	Wed Oct  9 16:31:10 2002
@@ -33,7 +33,7 @@
      int ret = 0;
      pid_t pid;
      __u32 version;
-     task_t *target;
+     task_t *target = current;
      struct __user_cap_data_struct data;
 
      if (get_user(version, &header->version))
@@ -52,21 +52,20 @@
              return -EINVAL;
 
      spin_lock(&task_capability_lock);
-     read_lock(&tasklist_lock); 
 
-     target = find_task_by_pid(pid);
-     if (!target) {
-          ret = -ESRCH;
-          goto out;
+     if (pid && pid != current->pid) {
+	     read_lock(&tasklist_lock); 
+	     target = find_task_by_pid(pid);
+	     read_unlock(&tasklist_lock); 
+	     if (!target) {
+	          ret = -ESRCH;
+	          goto out;
+	     }
      }
 
-     data.permitted = cap_t(target->cap_permitted);
-     data.inheritable = cap_t(target->cap_inheritable); 
-     data.effective = cap_t(target->cap_effective);
      ret = security_ops->capget(target, &data.effective, &data.inheritable, &data.permitted);
 
 out:
-     read_unlock(&tasklist_lock); 
      spin_unlock(&task_capability_lock);
 
      if (!ret && copy_to_user(dataptr, &data, sizeof data))
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-11-20  2:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-10  0:15 [PATCH] 2.5.41 capget fix Chris Wright
2002-10-10 19:36 ` Linus Torvalds
2002-10-10 21:47   ` Chris Wright
2002-10-12  2:58     ` Linus Torvalds
2002-11-19 21:14       ` [PATCH] sys_capget should use current if the pid argument is 0 Daniel Jacobowitz
2002-11-20  0:55         ` Chris Wright
2002-11-20  2:49           ` [PATCH] remove duplicated assignment from sys_capget Chris Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox