All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: James Morris <jmorris@namei.org>,
	linux-kernel@vger.kernel.org, sds@tycho.nsa.gov,
	morgan@kernel.org, selinux@tycho.nsa.gov
Subject: Re: [PATCH] capability: WARN when invalid capability is requested rather than BUG/panic
Date: Tue, 30 Sep 2008 12:07:23 -0400	[thread overview]
Message-ID: <1222790843.28251.92.camel@localhost.localdomain> (raw)
In-Reply-To: <20080930153820.GA28616@us.ibm.com>

On Tue, 2008-09-30 at 10:38 -0500, Serge E. Hallyn wrote:
> Quoting Eric Paris (eparis@redhat.com):
> > On Wed, 2008-10-01 at 00:23 +1000, James Morris wrote:
> > > On Tue, 30 Sep 2008, Eric Paris wrote:
> > > 
> > > > This patch adds a WARN_ONCE() to cap_capable() so we will stop
> > > > dereferencing random spots of memory and will cleanly tell the obviously
> > > > broken driver that it doesn't have that ridiculous permissions.  No idea
> > > > if the driver is going to handle EPERM but anything that calls capable
> > > > and doesn't expect a denial has got to be the worst piece of code ever
> > > > written.....  I could return EINVAL, but I think its clear that noone
> > > > has capabilities over 64 so clearly they don't have that permission.
> > > > 
> > > > This 'could' be considered a regression since 2.6.24.  Neither SELinux
> > > > nor the capabilities system had a problem with ginormous request values
> > > > until we got 64 bit support, although this is OBVIOUSLY a bug with the
> > > > out of tree closed source driver....
> > > 
> > > An issue here is whether we should be adding workarounds in the mainline 
> > > kernel for buggy closed drivers.  Papering over problems rather than 
> > > getting them fixed does not seem like a winning approach.  Especially 
> > > problems which are unexpectedly messing with kernel security APIs.
> > 
> > I don't know, looking at the feelings on "Can userspace bugs be kernel
> > regressions" leads me to believe that when we break something that once
> > worked we are supposed to fix it.
> > 
> > http://lwn.net/Articles/292143/
> > 
> > I don't think the proprietary closed source nature of the driver makes
> > it any less our problem
> 
> The kernel-space nature of the driver is the distinction here.
> 
> > to not make changes which cause the kernel to
> > esplode.
> > 
> > > Also, won't this encourage vendors of such drivers to continue with this 
> > > behavior, while discouraging those vendors who are doing the right thing?
> > 
> > Discouraging people who open source their drivers and put them in the
> > kernel?  obviously not.  encouraging crap?  well, I hope we fix
> > regressions no matter how they are found...
> > 
> > > Do we know if this even really helps the user?  For all we know, the 
> > > driver may simply crash differently with an -EPERM.
> > 
> > Well, before the 64 bit capabilities change we did:
> > 
> > (cap_t(c) & CAP_TO_MASK(flag))
> > 
> > so a huge value for "flag" got masked off.
> > 
> > After 64 bit capabilities we do:
> > 
> > ((c).cap[CAP_TO_INDEX(flag)] & CAP_TO_MASK(flag))
> 
> Perhaps we should have CAP_TO_INDEX mask itself?
> 
> #define CAP_TO_INDEX(x)		(((x) >> 5) & _KERNEL_CAPABILITY_U32S)

Well, you save a branch and won't get the pagefault so it does 'fix' the
pagefault/panic from cap code.  It doesn't tell us when others screw up
and SELinux is still possibly going to BUG().  We are also going to
actually be returning a permission decision not on what was requested
but on something wholely different.

I like mine better, but I'm ok with yours and can just do my changes in
SELinux if this is how cap wants to handle it.  I don't really like the
idea of mutating the inputs and then making the security decision based
on that mutation rather than on the original inputs (and yes, I realize
that exactly what 2.6.24 was doing)

> Though I still think it's not unreasonable to simply ask for the driver
> to be fixed.

I'm not going to argue that the driver needs fixed and that is the real
problem.  I know its been filed with them and the response was that
there is no support for linux.  I have today tried to poke the path I
know of between Red Hat and them to ask them to take a look.


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

WARNING: multiple messages have this Message-ID (diff)
From: Eric Paris <eparis@redhat.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: James Morris <jmorris@namei.org>,
	linux-kernel@vger.kernel.org, sds@tycho.nsa.gov,
	morgan@kernel.org, selinux@tycho.nsa.gov
Subject: Re: [PATCH] capability: WARN when invalid capability is requested rather than BUG/panic
Date: Tue, 30 Sep 2008 12:07:23 -0400	[thread overview]
Message-ID: <1222790843.28251.92.camel@localhost.localdomain> (raw)
In-Reply-To: <20080930153820.GA28616@us.ibm.com>

On Tue, 2008-09-30 at 10:38 -0500, Serge E. Hallyn wrote:
> Quoting Eric Paris (eparis@redhat.com):
> > On Wed, 2008-10-01 at 00:23 +1000, James Morris wrote:
> > > On Tue, 30 Sep 2008, Eric Paris wrote:
> > > 
> > > > This patch adds a WARN_ONCE() to cap_capable() so we will stop
> > > > dereferencing random spots of memory and will cleanly tell the obviously
> > > > broken driver that it doesn't have that ridiculous permissions.  No idea
> > > > if the driver is going to handle EPERM but anything that calls capable
> > > > and doesn't expect a denial has got to be the worst piece of code ever
> > > > written.....  I could return EINVAL, but I think its clear that noone
> > > > has capabilities over 64 so clearly they don't have that permission.
> > > > 
> > > > This 'could' be considered a regression since 2.6.24.  Neither SELinux
> > > > nor the capabilities system had a problem with ginormous request values
> > > > until we got 64 bit support, although this is OBVIOUSLY a bug with the
> > > > out of tree closed source driver....
> > > 
> > > An issue here is whether we should be adding workarounds in the mainline 
> > > kernel for buggy closed drivers.  Papering over problems rather than 
> > > getting them fixed does not seem like a winning approach.  Especially 
> > > problems which are unexpectedly messing with kernel security APIs.
> > 
> > I don't know, looking at the feelings on "Can userspace bugs be kernel
> > regressions" leads me to believe that when we break something that once
> > worked we are supposed to fix it.
> > 
> > http://lwn.net/Articles/292143/
> > 
> > I don't think the proprietary closed source nature of the driver makes
> > it any less our problem
> 
> The kernel-space nature of the driver is the distinction here.
> 
> > to not make changes which cause the kernel to
> > esplode.
> > 
> > > Also, won't this encourage vendors of such drivers to continue with this 
> > > behavior, while discouraging those vendors who are doing the right thing?
> > 
> > Discouraging people who open source their drivers and put them in the
> > kernel?  obviously not.  encouraging crap?  well, I hope we fix
> > regressions no matter how they are found...
> > 
> > > Do we know if this even really helps the user?  For all we know, the 
> > > driver may simply crash differently with an -EPERM.
> > 
> > Well, before the 64 bit capabilities change we did:
> > 
> > (cap_t(c) & CAP_TO_MASK(flag))
> > 
> > so a huge value for "flag" got masked off.
> > 
> > After 64 bit capabilities we do:
> > 
> > ((c).cap[CAP_TO_INDEX(flag)] & CAP_TO_MASK(flag))
> 
> Perhaps we should have CAP_TO_INDEX mask itself?
> 
> #define CAP_TO_INDEX(x)		(((x) >> 5) & _KERNEL_CAPABILITY_U32S)

Well, you save a branch and won't get the pagefault so it does 'fix' the
pagefault/panic from cap code.  It doesn't tell us when others screw up
and SELinux is still possibly going to BUG().  We are also going to
actually be returning a permission decision not on what was requested
but on something wholely different.

I like mine better, but I'm ok with yours and can just do my changes in
SELinux if this is how cap wants to handle it.  I don't really like the
idea of mutating the inputs and then making the security decision based
on that mutation rather than on the original inputs (and yes, I realize
that exactly what 2.6.24 was doing)

> Though I still think it's not unreasonable to simply ask for the driver
> to be fixed.

I'm not going to argue that the driver needs fixed and that is the real
problem.  I know its been filed with them and the response was that
there is no support for linux.  I have today tried to poke the path I
know of between Red Hat and them to ask them to take a look.


  reply	other threads:[~2008-09-30 16:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 13:55 [PATCH] capability: WARN when invalid capability is requested rather than BUG/panic Eric Paris
2008-09-30 13:55 ` Eric Paris
2008-09-30 14:23 ` James Morris
2008-09-30 14:23   ` James Morris
2008-09-30 14:36   ` Eric Paris
2008-09-30 14:36     ` Eric Paris
2008-09-30 15:38     ` Serge E. Hallyn
2008-09-30 15:38       ` Serge E. Hallyn
2008-09-30 16:07       ` Eric Paris [this message]
2008-09-30 16:07         ` Eric Paris
2008-09-30 16:28         ` Serge E. Hallyn
2008-09-30 16:28           ` Serge E. Hallyn
2008-09-30 17:22           ` Eric Paris
2008-09-30 17:22             ` Eric Paris
2008-09-30 17:28             ` Arjan van de Ven
2008-10-01 15:32               ` Eric Paris
2008-10-01 15:32                 ` Eric Paris
2008-10-01 15:39                 ` Arjan van de Ven
2008-10-01 15:44                 ` Serge E. Hallyn
2008-10-01 15:44                   ` Serge E. Hallyn
2008-10-05  1:30           ` Andrew G. Morgan
2008-10-05  1:30             ` Andrew G. Morgan
     [not found] <bhO5y-S0-29@gated-at.bofh.it>
     [not found] ` <bhOyr-1kZ-5@gated-at.bofh.it>
     [not found]   ` <bhOyr-1kZ-3@gated-at.bofh.it>
     [not found]     ` <bhPuC-2yN-5@gated-at.bofh.it>
     [not found]       ` <bhPXy-3jl-13@gated-at.bofh.it>
     [not found]         ` <bhQh0-3CK-9@gated-at.bofh.it>
     [not found]           ` <bhRd4-4RS-9@gated-at.bofh.it>
     [not found]             ` <bhRd8-4RS-27@gated-at.bofh.it>
     [not found]               ` <bibY4-6WP-13@gated-at.bofh.it>
2008-10-01 19:36                 ` Bodo Eggert

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=1222790843.28251.92.camel@localhost.localdomain \
    --to=eparis@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morgan@kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=serue@us.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.