linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: Andrew Morton <akpm@linuxfoundation.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
	Serge Hallyn <serge.hallyn@ubuntu.com>,
	James Morris <james.l.morris@oracle.com>,
	Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Ted Ts'o <tytso@mit.edu>, "Andrew G. Morgan" <morgan@kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Austin S Hemmelgarn <ahferroin7@gmail.com>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	Aaron Jones <aaronmdjones@gmail.com>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Markku Savela <msa@moth.iki.fi>,
	Kees Cook <keescook@chromium.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Christoph Lameter <cl@linux.com>,
	Andy Lutomirski <luto@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>
Subject: [PATCH v4 2/2] capabilities: Add a securebit to disable PR_CAP_AMBIENT_RAISE
Date: Tue, 14 Jul 2015 12:46:16 -0700	[thread overview]
Message-ID: <880e650ee1f52742f20c6a7370c0de22876ebf85.1436903028.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1436903028.git.luto@kernel.org>
In-Reply-To: <cover.1436903028.git.luto@kernel.org>

Per Andrew Morgan's request, add a securebit to allow admins to
disable PR_CAP_AMBIENT_RAISE.  This securebit will prevent processes
from adding capabilities to their ambient set.

For simplicity, this disables PR_CAP_AMBIENT_RAISE entirely rather
than just disabling setting previously cleared bits.

Acked-By: Andrew G. Morgan <morgan@kernel.org>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Aaron Jones <aaronmdjones@gmail.com>
CC: Ted Ts'o <tytso@mit.edu>
Cc: linux-security-module@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-api@vger.kernel.org
Cc: akpm@linuxfoundation.org
Cc: Andrew G. Morgan <morgan@kernel.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: Markku Savela <msa@moth.iki.fi>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 include/uapi/linux/securebits.h | 11 ++++++++++-
 security/commoncap.c            |  3 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/securebits.h b/include/uapi/linux/securebits.h
index 985aac9e6bf8..35ac35cef217 100644
--- a/include/uapi/linux/securebits.h
+++ b/include/uapi/linux/securebits.h
@@ -43,9 +43,18 @@
 #define SECBIT_KEEP_CAPS	(issecure_mask(SECURE_KEEP_CAPS))
 #define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED))
 
+/* When set, a process cannot add new capabilities to its ambient set. */
+#define SECURE_NO_CAP_AMBIENT_RAISE		6
+#define SECURE_NO_CAP_AMBIENT_RAISE_LOCKED	7  /* make bit-6 immutable */
+
+#define SECBIT_NO_CAP_AMBIENT_RAISE (issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
+#define SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED \
+			(issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED))
+
 #define SECURE_ALL_BITS		(issecure_mask(SECURE_NOROOT) | \
 				 issecure_mask(SECURE_NO_SETUID_FIXUP) | \
-				 issecure_mask(SECURE_KEEP_CAPS))
+				 issecure_mask(SECURE_KEEP_CAPS) | \
+				 issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
 #define SECURE_ALL_LOCKS	(SECURE_ALL_BITS << 1)
 
 #endif /* _UAPI_LINUX_SECUREBITS_H */
diff --git a/security/commoncap.c b/security/commoncap.c
index 1f74dde1063e..1832cf701c3d 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -993,7 +993,8 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 			if (arg2 == PR_CAP_AMBIENT_RAISE &&
 			    (!cap_raised(current_cred()->cap_permitted, arg3) ||
 			     !cap_raised(current_cred()->cap_inheritable,
-					 arg3)))
+					 arg3) ||
+			     issecure(SECURE_NO_CAP_AMBIENT_RAISE)))
 				return -EPERM;
 
 			new = prepare_creds();
-- 
2.4.3

      parent reply	other threads:[~2015-07-14 19:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 19:46 [PATCH v4 0/2] capabilities: Ambient capability patchset Andy Lutomirski
2015-07-14 19:46 ` [PATCH v4 1/2] capabilities: Ambient capabilities Andy Lutomirski
     [not found]   ` <9f660ee708e58892bfa7012b6b9c840298e24544.1436903028.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-15 11:13     ` James Morris
     [not found]       ` <alpine.LRH.2.11.1507152033420.8351-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
2015-07-15 17:09         ` Andy Lutomirski
     [not found]           ` <CALCETrWMBZ0p7P1FvtrYp5ChJXvvRzy0JpjS8KwUUa5m9gqgQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-17 20:40             ` Christoph Lameter
     [not found]               ` <alpine.DEB.2.11.1507171539590.13763-wcBtFHqTun5QOdAKl3ChDw@public.gmane.org>
2015-07-17 20:50                 ` Andrew Morton
2015-07-17 23:10                   ` Kees Cook
     [not found]                     ` <CAGXu5j+V0fMae5OOHwU5DcMrG0TCANYOTfbz5+LDZZqYKcXAaw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-17 23:21                       ` Andy Lutomirski
2015-07-14 19:46 ` Andy Lutomirski [this message]

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=880e650ee1f52742f20c6a7370c0de22876ebf85.1436903028.git.luto@kernel.org \
    --to=luto@kernel.org \
    --cc=aaronmdjones@gmail.com \
    --cc=ahferroin7@gmail.com \
    --cc=akpm@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=corbet@lwn.net \
    --cc=james.l.morris@oracle.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=morgan@kernel.org \
    --cc=msa@moth.iki.fi \
    --cc=mtk.manpages@gmail.com \
    --cc=serge.hallyn@canonical.com \
    --cc=serge.hallyn@ubuntu.com \
    --cc=serge@hallyn.com \
    --cc=tytso@mit.edu \
    --cc=zohar@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).