Hi all!
A couple of months ago we discussed the possibility of improving the getrusage
syscall to read usage information about tasks belonging to the same owner
(not just about current and children).
After an extensive discussion on the mailing list, some of us agreed about the
following patch. Some others, instead, said that it is too permissive.
Should we definitely drop this idea ??
Thanks,
Claudio
Signed-off-by: Claudio Scordino <[email protected]>
--- sys.c 2006-04-18 12:54:38.000000000 -0400
+++ sys.new.c 2006-04-18 12:58:41.000000000 -0400
@@ -1767,9 +1767,29 @@
asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
{
- if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
- return -EINVAL;
- return getrusage(current, who, ru);
+ struct rusage r;
+ struct task_struct* tsk = current;
+ read_lock(&tasklist_lock);
+ if ((who != RUSAGE_SELF) && (who != RUSAGE_CHILDREN)) {
+ tsk = find_task_by_pid(who);
+ if ((tsk == NULL) || (who <=0))
+ goto bad;
+ if (((current->uid != tsk->euid) ||
+ (current->uid != tsk->suid) ||
+ (current->uid != tsk->uid) ||
+ (current->gid != tsk->egid) ||
+ (current->gid != tsk->sgid) ||
+ (current->gid != tsk->gid)) && !capable(CAP_SYS_PTRACE))
+ goto bad;
+ who = RUSAGE_SELF;
+ }
+ k_getrusage(tsk, who, &r);
+ read_unlock(&tasklist_lock);
+ return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
+
+bad:
+ read_unlock(&tasklist_lock);
+ return tsk ? -EPERM : -EINVAL;
}
asmlinkage long sys_umask(int mask)
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]