From: Andrew Morton <akpm@osdl.org>
To: e8607062@student.tuwien.ac.at
Cc: linux-kernel@vger.kernel.org, sopwith@redhat.com
Subject: Re: [PATCH 2.6.13-rc6 1/2] New Syscall: get rlimits of any process
Date: Sat, 20 Aug 2005 18:11:02 -0700 [thread overview]
Message-ID: <20050820181102.725a4817.akpm@osdl.org> (raw)
In-Reply-To: <1123868902.10923.5.camel@w2>
Wieland Gmeiner <e8607062@student.tuwien.ac.at> wrote:
>
> +asmlinkage long sys_getprlimit(pid_t pid, unsigned int resource, struct rlimit __user *rlim)
> +{
> + struct rlimit value;
> + task_t *p;
> + int retval = -EINVAL;
> +
> + if (resource >= RLIM_NLIMITS)
> + goto out_nounlock;
> +
> + if (pid < 0)
> + goto out_nounlock;
> +
> + retval = -ESRCH;
> + if (pid == 0) {
> + p = current;
> + } else {
> + read_lock(&tasklist_lock);
> + p = find_task_by_pid(pid);
> + }
> + if (p) {
> + retval = -EPERM;
> + if ((current->euid ^ p->suid) && (current->euid ^ p->uid) &&
> + (current->uid ^ p->suid) && (current->uid ^ p->uid) &&
> + !capable(CAP_SYS_RESOURCE))
> + goto out_unlock;
> +
> + task_lock(p->group_leader);
> + value = p->signal->rlim[resource];
> + task_unlock(p->group_leader);
There isn't much point in taking task_lock() here. The value can change
after the lock has been dropped anyway.
> + retval = copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;
It's not legal to perform copy_*_user() (which sleeps) inside read_lock(),
write_lock(), spin_lock(), preempt_diable() or, really,
local_irq_disable().
> + }
> + if (pid == 0)
> + goto out_nounlock;
> +
> +out_unlock:
> + read_unlock(&tasklist_lock);
prev parent reply other threads:[~2005-08-21 1:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-12 17:48 Wieland Gmeiner
2005-08-12 17:53 ` [PATCH 2.6.13-rc6 2/2] New Syscall: set " Wieland Gmeiner
2005-08-13 22:11 ` [PATCH 2.6.13-rc6 1/2] New Syscall: get " Greg KH
2005-08-16 17:34 ` Wieland Gmeiner
2005-08-16 17:50 ` Greg KH
2005-08-16 17:55 ` Kyle Moffett
2005-08-21 1:11 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050820181102.725a4817.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=e8607062@student.tuwien.ac.at \
--cc=linux-kernel@vger.kernel.org \
--cc=sopwith@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome