lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 18 May 2010 15:39:25 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	David Howells <dhowells@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Andrew Tridgell <tridge@...ba.org>,
	Eric Paris <eparis@...isplace.org>,
	Jakub Jelinek <jakub@...hat.com>,
	James Morris <jmorris@...ei.org>,
	Roland McGrath <roland@...hat.com>,
	Stephen Smalley <sds@...ho.nsa.gov>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] signals: check_kill_permission: don't check creds if
	same_thread_group()

On 05/18, David Howells wrote:
>
> Oleg Nesterov <oleg@...hat.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;
+			}
 		}
 	}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ