From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754627AbbCLN0E (ORCPT ); Thu, 12 Mar 2015 09:26:04 -0400 Received: from emvm-gh1-uea09.nsa.gov ([63.239.67.10]:51259 "EHLO emvm-gh1-uea09.nsa.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751792AbbCLNZ7 (ORCPT ); Thu, 12 Mar 2015 09:25:59 -0400 X-TM-IMSS-Message-ID: <604c8f9b000e2854@nsa.gov> Message-ID: <550193AA.7060009@tycho.nsa.gov> Date: Thu, 12 Mar 2015 09:24:58 -0400 From: Stephen Smalley Organization: National Security Agency User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Casey Schaufler , James Morris , James Morris , LSM , LKLM CC: Paul Moore , John Johansen , Tetsuo Handa , Eric Paris , Kees Cook Subject: Re: [PATCH 8/7 v21] LSM: Fixes for issues found in review References: <54FE4553.3000209@schaufler-ca.com> <54FE46EF.4000708@schaufler-ca.com> <5500708B.3050101@tycho.nsa.gov> <55008DD0.3030402@schaufler-ca.com> <5500967A.3040203@tycho.nsa.gov> <5500C4D6.7070302@schaufler-ca.com> In-Reply-To: <5500C4D6.7070302@schaufler-ca.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/11/2015 06:42 PM, Casey Schaufler wrote: > Subject: [PATCH 8/7 v21] LSM: Fixes for issues found in review > > Correct capability hook uses that hadn't been done properly in the 6/7 patch. > > Signed-off-by: Casey Schaufler > Reported-by: Stephen Smalley Acked-by: Stephen Smalley > > --- > > security/apparmor/domain.c | 8 +++----- > security/selinux/hooks.c | 15 +-------------- > 2 files changed, 4 insertions(+), 19 deletions(-) > > diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c > index b09fff7..dc0027b 100644 > --- a/security/apparmor/domain.c > +++ b/security/apparmor/domain.c > @@ -529,15 +529,13 @@ cleanup: > */ > int apparmor_bprm_secureexec(struct linux_binprm *bprm) > { > - int ret = cap_bprm_secureexec(bprm); > - > /* the decision to use secure exec is computed in set_creds > * and stored in bprm->unsafe. > */ > - if (!ret && (bprm->unsafe & AA_SECURE_X_NEEDED)) > - ret = 1; > + if (bprm->unsafe & AA_SECURE_X_NEEDED) > + return 1; Not your fault but for the AA folks, I think this is a layering violation; security modules shouldn't directly set bits in brpm->unsafe as they could be used at any time by the core kernel; we have our own bprm->security field for any module-private flags. If there was a general need for such a flag, it should be defined with the rest of the unsafe flags so that it is properly reserved. > > - return ret; > + return 0; > } > > /** > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 3fd8610..e71c797 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2008,7 +2008,7 @@ static int selinux_ptrace_traceme(struct task_struct *parent) > static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, > kernel_cap_t *inheritable, kernel_cap_t *permitted) > { > - return cap_capget(target, effective, inheritable, permitted); > + return current_has_perm(target, PROCESS__GETCAP); > } > > static int selinux_capset(struct cred *new, const struct cred *old, > @@ -2016,13 +2016,6 @@ static int selinux_capset(struct cred *new, const struct cred *old, > const kernel_cap_t *inheritable, > const kernel_cap_t *permitted) > { > - int error; > - > - error = cap_capset(new, old, > - effective, inheritable, permitted); > - if (error) > - return error; > - > return cred_has_perm(old, new, PROCESS__SETCAP); > } > > @@ -2039,12 +2032,6 @@ static int selinux_capset(struct cred *new, const struct cred *old, > static int selinux_capable(const struct cred *cred, struct user_namespace *ns, > int cap, int audit) > { > - int rc; > - > - rc = cap_capable(cred, ns, cap, audit); > - if (rc) > - return rc; > - > return cred_has_capability(cred, cap, audit); > } > >