From: Oleg Nesterov <oleg@redhat.com>
To: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andrew Tridgell <tridge@samba.org>,
Eric Paris <eparis@parisplace.org>,
Jakub Jelinek <jakub@redhat.com>,
James Morris <jmorris@namei.org>,
Roland McGrath <roland@redhat.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signals: check_kill_permission: don't check creds if same_thread_group()
Date: Tue, 18 May 2010 15:39:25 +0200 [thread overview]
Message-ID: <20100518133925.GA1353@redhat.com> (raw)
In-Reply-To: <2996.1274172907@redhat.com>
On 05/18, David Howells wrote:
>
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > Also, move "cred = current_cred()" down to avoid calling get_current()
> > twice.
>
> I don't see what you mean by this. same_thread_group() doesn't call
> current_cred(), so why this change?
Yes, but both current_cred() and same_thread_group(current, t) call
get_current(), and gcc doesn't cache the result because we call
audit_signal_info() in between.
In fact, initially I was going to send the patch below, but then
decided to make a more simple change.
Oleg.
--- x/kernel/signal.c
+++ x/kernel/signal.c
@@ -642,8 +642,6 @@ static inline bool si_fromuser(const str
static int check_kill_permission(int sig, struct siginfo *info,
struct task_struct *t)
{
- const struct cred *cred = current_cred(), *tcred;
- struct pid *sid;
int error;
if (!valid_signal(sig))
@@ -656,23 +654,29 @@ static int check_kill_permission(int sig
if (error)
return error;
- tcred = __task_cred(t);
- if ((cred->euid ^ tcred->suid) &&
- (cred->euid ^ tcred->uid) &&
- (cred->uid ^ tcred->suid) &&
- (cred->uid ^ tcred->uid) &&
- !capable(CAP_KILL)) {
- switch (sig) {
- case SIGCONT:
- sid = task_session(t);
- /*
- * We don't return the error if sid == NULL. The
- * task was unhashed, the caller must notice this.
- */
- if (!sid || sid == task_session(current))
- break;
- default:
- return -EPERM;
+ if (!same_thread_group(current, t)) {
+ const struct cred *cred = current_cred();
+ const struct cred *tcred = __task_cred(t);
+ struct pid *sid;
+
+ if ((cred->euid ^ tcred->suid) &&
+ (cred->euid ^ tcred->uid) &&
+ (cred->uid ^ tcred->suid) &&
+ (cred->uid ^ tcred->uid) &&
+ !capable(CAP_KILL)) {
+ switch (sig) {
+ case SIGCONT:
+ sid = task_session(t);
+ /*
+ * We don't return the error if sid == NULL.
+ * The task was unhashed, the caller must
+ * notice this.
+ */
+ if (!sid || sid == task_session(current))
+ break;
+ default:
+ return -EPERM;
+ }
}
}
next prev parent reply other threads:[~2010-05-18 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-17 19:54 [PATCH] signals: check_kill_permission: don't check creds if same_thread_group() Oleg Nesterov
2010-05-18 1:25 ` Roland McGrath
2010-05-18 8:55 ` David Howells
2010-05-18 13:39 ` Oleg Nesterov [this message]
2010-05-18 13:50 ` David Howells
2010-05-18 14:08 ` Oleg Nesterov
2010-05-20 19:42 ` Andrew Morton
2010-05-20 20:02 ` Roland McGrath
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=20100518133925.GA1353@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=eparis@parisplace.org \
--cc=jakub@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=sds@tycho.nsa.gov \
--cc=tridge@samba.org \
/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