mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Stephen Smalley <sds@epoch.ncsc.mil>
Cc: Andy Lutomirski <luto@myrealbox.com>,
	Chris Wright <chrisw@osdl.org>, Andrew Morton <akpm@osdl.org>,
	Linus Torvalds <torvalds@osdl.org>,
	James Morris <jmorris@redhat.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: compute_creds fixup in -mm
Date: Wed, 21 Apr 2004 11:28:27 -0700	[thread overview]
Message-ID: <20040421112827.O21045@build.pdx.osdl.net> (raw)
In-Reply-To: <1082571199.9213.61.camel@moss-spartans.epoch.ncsc.mil>; from sds@epoch.ncsc.mil on Wed, Apr 21, 2004 at 02:13:19PM -0400

* Stephen Smalley (sds@epoch.ncsc.mil) wrote:
> On Wed, 2004-04-21 at 13:27, Andy Lutomirski wrote:
> > This doesn't fix selinux, though -- its apply_creds hook just blindly calls
> > commoncap's.  In fact, this breaks all attempts to get nested capability modules
> > right.  The problem is that, AFAICS, not only does ptrace_detach not take
> > task_lock, _exit() doesn't either.  So you get an equivalent race for the shared
> > state check.  I see two ways to fix that:
> 
> I didn't see Chris' patch.  I assume that the worst case is unexpected
> program failure due to lack of capability, right?  The SELinux security

The opposite.  You'd get a program with non-root euid, but full
capability set, and AT_SECURE set false.  My patch is below.

--- a/security/commoncap.c~compute_creds-lock	2004-04-21 00:54:34.000000000 -0700
+++ b/security/commoncap.c	2004-04-21 01:01:00.000000000 -0700
@@ -135,28 +135,26 @@
 
 	task_lock(current);
 
-	if (bprm->e_uid != current->uid || bprm->e_gid != current->gid) {
+	if (bprm->e_uid != current->uid || bprm->e_gid != current->gid ||
+	    !cap_issubset (new_permitted, current->cap_permitted)) {
 		current->mm->dumpable = 0;
 
-		if (must_not_trace_exec(current) && !capable(CAP_SETUID)) {
-			bprm->e_uid = current->uid;
-			bprm->e_gid = current->gid;
+		if (must_not_trace_exec(current)) {
+			if (!capable(CAP_SETUID)) {
+				bprm->e_uid = current->uid;
+				bprm->e_gid = current->gid;
+			}
+			if (!capable (CAP_SETPCAP)) {
+				new_permitted = cap_intersect (new_permitted,
+							current->cap_permitted);
+			}
+
 		}
 	}
 
 	current->suid = current->euid = current->fsuid = bprm->e_uid;
 	current->sgid = current->egid = current->fsgid = bprm->e_gid;
 
-	if (!cap_issubset (new_permitted, current->cap_permitted)) {
-		current->mm->dumpable = 0;
-
-		if (must_not_trace_exec (current) && !capable (CAP_SETPCAP)) {
-			new_permitted = cap_intersect (new_permitted,
-						       current->
-						       cap_permitted);
-		}
-	}
-
 	/* For init, we want to retain the capabilities set
 	 * in the init_task struct. Thus we skip the usual
 	 * capability rules */



  reply	other threads:[~2004-04-21 18:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040421010621.L22989@build.pdx.osdl.net>
2004-04-21 17:27 ` Andy Lutomirski
2004-04-21 18:13   ` Stephen Smalley
2004-04-21 18:28     ` Chris Wright [this message]
2004-04-21 18:42       ` Stephen Smalley
2004-04-21 18:54         ` Chris Wright
2004-04-21 19:37         ` Andy Lutomirski
2004-04-21 20:10           ` Stephen Smalley
2004-04-21 19:07   ` Chris Wright
     [not found] <fa.n7n31hd.1k7ce37@ifi.uio.no>
     [not found] ` <fa.f9m11dm.206fg4@ifi.uio.no>
2004-04-21 20:36   ` Andy Lutomirski

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=20040421112827.O21045@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@myrealbox.com \
    --cc=sds@epoch.ncsc.mil \
    --cc=torvalds@osdl.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

all inboxes | Powered by JetHome®