From: Chris Wright <chrisw@osdl.org>
To: Wieland Gmeiner <e8607062@student.tuwien.ac.at>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Elliot Lee <sopwith@redhat.com>
Subject: Re: [PATCH 2.6.13-rc6 1/2] New Syscall: get rlimits of any process (update)
Date: Wed, 17 Aug 2005 18:17:28 -0700 [thread overview]
Message-ID: <20050818011728.GP7991@shell0.pdx.osdl.net> (raw)
In-Reply-To: <1124326652.8359.3.camel@w2>
* Wieland Gmeiner (e8607062@student.tuwien.ac.at) wrote:
> diff -uprN -X linux-2.6.13-rc6-vanilla/Documentation/dontdiff linux-2.6.13-rc6-vanilla/kernel/sys.c linux-2.6.13-rc6-getprlimit/kernel/sys.c
> --- linux-2.6.13-rc6-vanilla/kernel/sys.c 2005-08-09 16:03:21.000000000 +0200
> +++ linux-2.6.13-rc6-getprlimit/kernel/sys.c 2005-08-17 23:56:40.000000000 +0200
> @@ -1604,6 +1604,63 @@ asmlinkage long sys_setrlimit(unsigned i
> }
>
> /*
> + * As ptrace implies the ability to execute arbitrary code in the given
> + * process, which means that the calling process could obtain and set
> + * rlimits for that process without getprlimit/setprlimit anyways,
> + * we use the same permission checks as ptrace.
> + */
> +
> +static inline int prlim_check_perm(task_t *task)
> +{
> + return ((current->uid == task->euid) &&
> + (current->uid == task->suid) &&
> + (current->uid == task->uid) &&
> + (current->gid == task->egid) &&
> + (current->gid == task->sgid) &&
> + (current->gid == task->gid)) || capable(CAP_SYS_RESOURCE);
> +}
This comment and the code aren't matching. CAP_SYS_RESOUCE now means
effective on any other process, which it never did before. That should
be given careful thought. CAP_SYS_PTRACE indeed would let you call
get/setrlimit in traced task, perhaps that what you meant?
> +
> +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 (!prlim_check_perm(p))
> + goto out_unlock;
> +
> + task_lock(p->group_leader);
> + value = p->signal->rlim[resource];
> + task_unlock(p->group_leader);
> + retval = copy_to_user(rlim, &value, sizeof(*rlim)) ? -EFAULT : 0;
Do not call copy_to_user() with tasklist_lock held. Also, this is the
same basic code as sys_getrlimit(). So they should share code. (IOW,
sys_getrlimit() is now really sys_getprlimit(0,...))
thanks,
-chris
next prev parent reply other threads:[~2005-08-18 1:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-18 0:57 [PATCH 2.6.13-rc6 1/2] New Syscall: get rlimits of any process (update) Wieland Gmeiner
2005-08-18 1:02 ` [PATCH 2.6.13-rc6 2/2] New Syscall: set " Wieland Gmeiner
2005-08-18 1:57 ` Chris Wright
2005-08-18 15:48 ` Stephen Smalley
2005-08-18 1:17 ` Chris Wright [this message]
2005-08-18 2:05 ` [PATCH 2.6.13-rc6 1/2] New Syscall: get " Andi Kleen
2005-08-18 16:19 ` Wieland Gmeiner
2005-08-18 16:40 ` James Morris
2005-08-18 17:49 ` Alan Cox
2005-08-19 17:11 ` Elliot Lee
2005-08-23 5:52 ` Ulrich Drepper
2005-08-18 18:17 ` Lee Revell
2005-08-18 23:13 ` Alan Cox
2005-08-18 23:16 ` Lee Revell
2005-08-19 0:29 ` Alan Cox
2005-08-19 0:15 ` Lee Revell
2005-08-22 5:15 ` Eric W. Biederman
[not found] <1124326652.8359.3.camel@w2.suse.lists.linux.kernel>
[not found] ` <p7364u40zld.fsf@verdi.suse.de.suse.lists.linux.kernel>
[not found] ` <1124381951.6251.14.camel@w2.suse.lists.linux.kernel>
2005-08-18 16:39 ` Andi Kleen
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=20050818011728.GP7991@shell0.pdx.osdl.net \
--to=chrisw@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