mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Eric Paris <eparis@redhat.com>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov,
	jwcart2@tycho.nsa.gov, spender@grsecurity.net, dwalsh@redhat.com,
	cl@linux-foundation.org, arjan@infradead.org,
	alan@lxorguk.ukuu.org.uk, kees@outflux.net, csellers@tresys.com,
	penguin-kernel@i-love.sakura.ne.jp,
	Andrew Morgan <morgan@kernel.org>
Subject: Re: [PATCH -v3 1/3] Capabilities: move cap_file_mmap to commoncap.c
Date: Thu, 30 Jul 2009 16:05:01 -0400	[thread overview]
Message-ID: <1248984301.11627.199.camel@moss-pluto.epoch.ncsc.mil> (raw)
In-Reply-To: <20090730200144.GB20292@us.ibm.com>

On Thu, 2009-07-30 at 15:01 -0500, Serge E. Hallyn wrote:
> Quoting Stephen Smalley (sds@tycho.nsa.gov):
> > On Thu, 2009-07-30 at 13:50 -0400, Eric Paris wrote:
> > > On Thu, 2009-07-30 at 11:58 -0400, Stephen Smalley wrote:
> > > > On Thu, 2009-07-30 at 10:54 -0500, Serge E. Hallyn wrote:
> > > > > Quoting Eric Paris (eparis@redhat.com):
> > > > > > On Thu, 2009-07-30 at 00:14 -0500, Serge E. Hallyn wrote:
> > > > > > > Quoting Eric Paris (eparis@redhat.com):
> > > > > > > > Currently we duplicate the mmap_min_addr test in cap_file_mmap and in
> > > > > > > > security_file_mmap if !CONFIG_SECURITY.  This patch moves cap_file_mmap
> > > > > > > > into commoncap.c and then calls that function directly from
> > > > > > > > security_file_mmap ifndef CONFIG_SECURITY like all of the other capability
> > > > > > > > checks are done.
> > > > > > > 
> > > > > > > It also
> > > > > > > 
> > > > > > > 	1. changes the return value in error case from -EACCES to
> > > > > > > 	   -EPERM
> > > > > > > 	2. no onger sets PF_SUPERPRIV in t->flags if the capability
> > > > > > > 	   is used.
> > > > > > > 
> > > > > > > Do we care about these?
> > > > > > 
> > > > > > Personally, not really, but I'll gladly put them back if you care.   #2
> > > > > > seems more interesting to me than number 1.   I actually kinda like
> > > > > > getting EPERM from caps rather than EACCES since them I know if I was
> > > > > > denied by selinux or by caps.....
> > > > > > 
> > > > > > -Eric
> > > > > 
> > > > > Yup, I asked bc I didn't particularly care myself.
> > > > > 
> > > > > I think I agree with you about -EPERM being better anyway.  However I
> > > > > (now) think in this case PF_SUPERPRIV definately should be set, as this
> > > > > is a clear use of a capability to do something that couldn't have been
> > > > > done without it.
> > > > 
> > > > On a related but different note, we should consider all current uses of
> > > > cap_capable(), as they represent capability checks that will not be
> > > > subject to a further restrictive check by other security modules.  In
> > > > this case and in the vm_enough_memory case, that is intentional, but not
> > > > so clear for other uses in commoncap.c.
> > > 
> > > Most of commoncap.c is called either as a secondary hook from the active
> > > lsm (aka selinux calls the commoncap.c functions) or in the !
> > > CONFIG_SECURITY case.
> > > 
> > > I'll audit this afternoon to see which of them might not fit these
> > > rules....
> > 
> > That isn't what I meant.  Most of the commoncap functions call capable()
> > rather than directly calling cap_capable(), thereby causing:
> > - PF_SUPERPRIV to be set, and
> > - The primary security module (e.g. SELinux) to apply its own
> > restrictive check.
> > 
> > That is useful as it allows SELinux or AppArmor or TOMOYO to veto e.g.
> > CAP_SYS_PTRACE without replicating the same logic within its own hook.
> > 
> > The current exceptions are:
> > cap_inh_is_capped() called from cap_capset(),
> > cap_task_prctl() in the PR_SET_SECUREBITS case,
> > cap_vm_enough_memory(),
> > cap_file_mmap() after your patch.
> > 
> > The latter two are indeed cases where we made a conscious choice that
> > SELinux would not apply its capability check against policy.  But the
> > first two are unclear to me.
> 
> cap_inh_is_capped:
> 
> I'm not sure why it's cap_capable() instead of capable().  However, if we
> switch to using capable(), then we should switch the conditions in the caller
> around, since at the moment just because the capable() check returned true
> doesn't mean that we actually end up needing it.
> 
> (CC:ing Andrew Morgan as I believe he wrote this and may have had a reason)
> 
> cap_task_prctl: I don't see any reason why that shouldn't be capable().
> 
> cap_vm_enough_memory(): I seem to recall we explicitly decided that we
> did not want PF_SUPERPRIV set in this case.

Yes - that one was intentional, as it gets applied to all tasks that
allocate mappings.  For the same reason, we don't audit that check in
SELinux.

> cap_file_mmap(): well now that you mention it, it does seem like SELinux
> would want a say in whether the task gets CAP_SYS_RAWIO here, so maybe
> it should be capable() after all?

No, we apply our own specific permission check for it.

-- 
Stephen Smalley
National Security Agency


  reply	other threads:[~2009-07-30 20:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29 18:56 Eric Paris
2009-07-29 18:56 ` [PATCH -v3 2/3] SELinux: call cap_file_mmap in selinux_file_mmap Eric Paris
2009-07-29 18:56 ` [PATCH -v3 3/3] Security/SELinux: seperate lsm specific mmap_min_addr Eric Paris
2009-07-30  5:14 ` [PATCH -v3 1/3] Capabilities: move cap_file_mmap to commoncap.c Serge E. Hallyn
2009-07-30 15:40   ` Eric Paris
2009-07-30 15:54     ` Serge E. Hallyn
2009-07-30 15:58       ` Stephen Smalley
2009-07-30 17:50         ` Eric Paris
2009-07-30 18:31           ` Eric Paris
2009-07-30 19:47             ` Stephen Smalley
2009-07-30 19:42           ` Stephen Smalley
2009-07-30 19:54             ` Stephen Smalley
2009-07-30 20:01             ` Serge E. Hallyn
2009-07-30 20:05               ` Stephen Smalley [this message]
2009-07-30 17:53       ` Eric Paris
2009-07-30 19:41         ` Serge E. Hallyn

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=1248984301.11627.199.camel@moss-pluto.epoch.ncsc.mil \
    --to=sds@tycho.nsa.gov \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arjan@infradead.org \
    --cc=cl@linux-foundation.org \
    --cc=csellers@tresys.com \
    --cc=dwalsh@redhat.com \
    --cc=eparis@redhat.com \
    --cc=jwcart2@tycho.nsa.gov \
    --cc=kees@outflux.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=morgan@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=selinux@tycho.nsa.gov \
    --cc=serue@us.ibm.com \
    --cc=spender@grsecurity.net \
    /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®