From: Chris Wright <chris@wirex.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.5.41 capget fix
Date: Thu, 10 Oct 2002 14:47:15 -0700 [thread overview]
Message-ID: <20021010144715.A30806@figure1.int.wirex.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0210101235290.2750-100000@penguin.transmeta.com>; from torvalds@transmeta.com on Thu, Oct 10, 2002 at 12:36:29PM -0700
* Linus Torvalds (torvalds@transmeta.com) wrote:
> On Wed, 9 Oct 2002, Chris Wright wrote:
> >
> > 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.
>
> This is not correct. You drop the tasklist_lock before you actually set
> read the capabilities, which means that by the time you read them, the
> task you looked up may not be there any more.
Doh...feeling dumb...
The patch below fixes my oversight. The locking is left the way it was,
and just the pid 0 part is fixed as well as the duplicate code removed.
This still applies against bk-curr and I tested it on 2.5.41.
thanks,
-chris
--- 2.5.41/kernel/capability.c Sun Sep 15 12:19:29 2002
+++ 2.4.41-capget/kernel/capability.c Thu Oct 10 14:36:29 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))
@@ -54,15 +54,14 @@
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) {
+ target = find_task_by_pid(pid);
+ 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:
next prev parent reply other threads:[~2002-10-10 21:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 0:15 Chris Wright
2002-10-10 19:36 ` Linus Torvalds
2002-10-10 21:47 ` Chris Wright [this message]
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
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=20021010144715.A30806@figure1.int.wirex.com \
--to=chris@wirex.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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