mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Lameter <cl@linux.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Serge Hallyn <serge.hallyn@ubuntu.com>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Aaron Jones <aaronmdjones@gmail.com>, "Ted Ts'o" <tytso@mit.edu>,
	LSM List <linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linuxfoundation.org>
Subject: Re: [capabilities] Allow normal inheritance for a configurable set of capabilities
Date: Tue, 3 Feb 2015 13:45:38 -0600 (CST)	[thread overview]
Message-ID: <alpine.DEB.2.11.1502031341100.7862@gentwo.org> (raw)
In-Reply-To: <54D10A50.5030707@schaufler-ca.com>

On Tue, 3 Feb 2015, Casey Schaufler wrote:

> > (I wasn't going to ask bc I assumed not, but heck maybe you're bored
> > on a desert island or snowed in and just looking for an excuse to hack :)
>
> Not at all bored, but I think this could be important.

Ok here is a draft of a patch that follows these ideas.

It also adds an ambient field and sets the field if a new capability

	CAP_AMBIENT_MASK

is set. The perm calcualtion is as suggested by Serge.


If CAP_AMBIENT_MASK is set the inheritable caps become the ambient ones.

If it is not set then the ambient caps are copied from the parent.


DRAFT --- not a working patch:

Index: linux/include/linux/capability.h
===================================================================
--- linux.orig/include/linux/capability.h	2015-02-03 13:25:03.000000000 -0600
+++ linux/include/linux/capability.h	2015-02-03 13:39:23.385424676 -0600
@@ -29,6 +29,7 @@ struct cpu_vfs_cap_data {
 	__u32 magic_etc;
 	kernel_cap_t permitted;
 	kernel_cap_t inheritable;
+	kernel_cap_t ambient;
 };

 #define _USER_CAP_HEADER_SIZE  (sizeof(struct __user_cap_header_struct))
Index: linux/include/uapi/linux/capability.h
===================================================================
--- linux.orig/include/uapi/linux/capability.h	2014-07-10 16:10:29.814424392 -0500
+++ linux/include/uapi/linux/capability.h	2015-02-03 13:26:13.231081452 -0600
@@ -351,8 +351,10 @@ struct vfs_cap_data {

 #define CAP_AUDIT_READ		37

+/* Set the current inheritable mask as the ambient inheritable mask */
+#define CAP_AMBIENT_MASK	38

-#define CAP_LAST_CAP         CAP_AUDIT_READ
+#define CAP_LAST_CAP         CAP_AMBIENT_MASK

 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)

Index: linux/security/commoncap.c
===================================================================
--- linux.orig/security/commoncap.c	2015-02-03 13:25:03.000000000 -0600
+++ linux/security/commoncap.c	2015-02-03 13:43:16.317859741 -0600
@@ -349,17 +349,24 @@ static inline int bprm_caps_from_vfs_cap
 	CAP_FOR_EACH_U32(i) {
 		__u32 permitted = caps->permitted.cap[i];
 		__u32 inheritable = caps->inheritable.cap[i];
+		__u32 ambient = caps->ambient.cap[i];

 		/*
 		 * pP' = (X & fP) | (pI & fI)
 		 */
 		new->cap_permitted.cap[i] =
 			(new->cap_bset.cap[i] & permitted) |
-			(new->cap_inheritable.cap[i] & inheritable);
+			(new->cap_inheritable.cap[i] & inheritable) |
+			(ambient & inheritable);

 		if (permitted & ~new->cap_permitted.cap[i])
 			/* insufficient to execute correctly */
 			ret = -EPERM;
+
+		if (capable(CAP_AMBIENT_MASK))
+			new->cap_ambient.cap[i] = inheritable;
+		else
+			new->cap_ambient.cap[i] = ambient;
 	}

 	/*
Index: linux/include/linux/cred.h
===================================================================
--- linux.orig/include/linux/cred.h	2014-12-18 11:17:49.731948737 -0600
+++ linux/include/linux/cred.h	2015-02-03 13:37:32.701019201 -0600
@@ -122,6 +122,7 @@ struct cred {
 	kernel_cap_t	cap_permitted;	/* caps we're permitted */
 	kernel_cap_t	cap_effective;	/* caps we can actually use */
 	kernel_cap_t	cap_bset;	/* capability bounding set */
+	kernel_cap_t	cap_ambient;	/* Ambient inherited caps */
 #ifdef CONFIG_KEYS
 	unsigned char	jit_keyring;	/* default keyring to attach requested
 					 * keys to */



  reply	other threads:[~2015-02-03 19:45 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 16:21 Christoph Lameter
2015-02-02 17:12 ` Serge Hallyn
2015-02-02 17:18   ` Andy Lutomirski
2015-02-02 18:09     ` Serge Hallyn
2015-02-03 15:16     ` Christoph Lameter
2015-02-03 15:23   ` Christoph Lameter
2015-02-03 15:55     ` Serge E. Hallyn
2015-02-03 17:18       ` Christoph Lameter
2015-02-03 17:26         ` Serge E. Hallyn
2015-02-04 15:15           ` Andrew G. Morgan
2015-02-04 15:50             ` Christoph Lameter
2015-02-04 15:56               ` Serge E. Hallyn
2015-02-04 16:12                 ` Andrew G. Morgan
2015-02-04 16:34                   ` Andy Lutomirski
2015-02-04 16:54                     ` Andrew G. Morgan
2015-02-04 17:34                       ` Serge E. Hallyn
2015-02-04 18:12                         ` Christoph Lameter
2015-02-04 16:43                   ` Christoph Lameter
2015-02-04 16:27                 ` Andy Lutomirski
2015-02-05  0:34             ` Serge E. Hallyn
2015-02-05 15:23               ` Serge E. Hallyn
2015-02-25 21:50     ` Pavel Machek
2015-02-25 23:59       ` Christoph Lameter
2015-02-26 12:27         ` Pavel Machek
2015-02-27 20:15           ` Andy Lutomirski
2015-02-27 20:48             ` Pavel Machek
2015-02-27 20:56               ` Andy Lutomirski
2015-02-27 22:47                 ` Pavel Machek
2015-02-02 17:54 ` Casey Schaufler
2015-02-02 18:08   ` Serge Hallyn
2015-02-02 18:47     ` Mimi Zohar
2015-02-02 19:05       ` Austin S Hemmelgarn
2015-02-02 20:35         ` Casey Schaufler
2015-02-03 16:04       ` Serge E. Hallyn
2015-02-02 19:00     ` Casey Schaufler
2015-02-05  0:20       ` Serge E. Hallyn
2015-02-02 20:37     ` Andy Lutomirski
2015-02-02 20:54       ` Casey Schaufler
2015-02-03 15:51         ` Serge E. Hallyn
2015-02-03 16:37           ` Casey Schaufler
2015-02-03 17:28             ` Serge E. Hallyn
2015-02-03 17:50               ` Casey Schaufler
2015-02-03 19:45                 ` Christoph Lameter [this message]
2015-02-03 20:13                   ` Andy Lutomirski
2015-02-03 23:14                     ` Christoph Lameter
2015-02-03 23:17                       ` Andy Lutomirski
2015-02-04  2:27                         ` Christoph Lameter
2015-02-04  6:05                         ` Markku Savela
2015-02-04 13:17                           ` Christoph Lameter
2015-02-04 13:41                             ` Markku Savela
2015-02-04 14:56                               ` Jarkko Sakkinen
2015-02-03 15:17       ` Christoph Lameter
2015-02-03 15:40         ` Casey Schaufler
2015-02-03 15:46       ` Serge E. Hallyn
2015-02-03 17:19         ` Christoph Lameter
2015-02-03 17:29           ` Serge E. Hallyn
2015-02-25 21:50     ` Pavel Machek

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=alpine.DEB.2.11.1502031341100.7862@gentwo.org \
    --to=cl@linux.com \
    --cc=aaronmdjones@gmail.com \
    --cc=akpm@linuxfoundation.org \
    --cc=casey@schaufler-ca.com \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=serge.hallyn@canonical.com \
    --cc=serge.hallyn@ubuntu.com \
    --cc=serge@hallyn.com \
    --cc=tytso@mit.edu \
    /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®