Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932175AbbFDWDF (ORCPT ); Thu, 4 Jun 2015 18:03:05 -0400 Received: from h2.hallyn.com ([78.46.35.8]:56804 "EHLO h2.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354AbbFDWDC (ORCPT ); Thu, 4 Jun 2015 18:03:02 -0400 Date: Thu, 4 Jun 2015 17:03:01 -0500 From: "Serge E. Hallyn" To: Andy Lutomirski Cc: Serge Hallyn , Andrew Morton , James Morris , Jarkko Sakkinen , "Ted Ts'o" , "Andrew G. Morgan" , Linux API , Mimi Zohar , Michael Kerrisk , Austin S Hemmelgarn , linux-security-module , Aaron Jones , Serge Hallyn , LKML , Markku Savela , Kees Cook , Jonathan Corbet , Christoph Lameter , Andy Lutomirski Subject: Re: [PATCH v3 2/2] capabilities: Add a securebit to disable PR_CAP_AMBIENT_RAISE Message-ID: <20150604220301.GA5920@mail.hallyn.com> References: <8b3a8b2fa031e043483f2f444f0b51aed0681e85.1432770087.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8b3a8b2fa031e043483f2f444f0b51aed0681e85.1432770087.git.luto@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3571 Lines: 86 On Wed, May 27, 2015 at 04:47:59PM -0700, Andy Lutomirski wrote: > 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 > Cc: Kees Cook > Cc: Christoph Lameter > Cc: Serge Hallyn Acked-by: Serge Hallyn > Cc: Andy Lutomirski > Cc: Jonathan Corbet > Cc: Aaron Jones > CC: Ted Ts'o > 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 > Cc: Mimi Zohar > Cc: Austin S Hemmelgarn > Cc: Markku Savela > Cc: Jarkko Sakkinen > Cc: Michael Kerrisk > Signed-off-by: Andy Lutomirski > --- > 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 835a7584f7ea..22b7b91c5eae 100644 > --- a/security/commoncap.c > +++ b/security/commoncap.c > @@ -987,7 +987,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.1.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/