selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: Paul Moore <paul@paul-moore.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>, selinux@vger.kernel.org
Subject: Re: [PATCH] selinux: replace BUG_ONs with WARN_ONs in avc.c
Date: Mon, 28 Jan 2019 16:43:06 +0100	[thread overview]
Message-ID: <CAFqZXNsVOZi9DO9qgdvmhgtw2iKxXovpdjLzYkuLJ2M72jyVaA@mail.gmail.com> (raw)
In-Reply-To: <CAHC9VhQuFPQ9C5=FxP1LEetZVHRsfmQV2qH5TErTaPuBW9wcsQ@mail.gmail.com>

On Mon, Jan 28, 2019 at 4:11 PM Paul Moore <paul@paul-moore.com> wrote:
> On Mon, Jan 28, 2019 at 8:23 AM Stephen Smalley <sds@tycho.nsa.gov> wrote:
> > On 1/26/19 5:18 AM, Ondrej Mosnacek wrote:
> > > These checks are only guarding against programming errors that could
> > > silently grant too many permissions. These cases are better handled with
> > > WARN_ON(), since it doesn't really help much to crash the machine in
> > > this case.
> > >
> > > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > > ---
> > >   security/selinux/avc.c | 4 ++--
> > >   1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/security/selinux/avc.c b/security/selinux/avc.c
> > > index 3a27418b20d7..84f108f4100a 100644
> > > --- a/security/selinux/avc.c
> > > +++ b/security/selinux/avc.c
> > > @@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state,
> > >       int rc = 0, rc2;
> > >
> > >       xp_node = &local_xp_node;
> > > -     BUG_ON(!requested);
> > > +     WARN_ON(!requested);
> >
> > Should this be:
> >         if (WARN_ON(!requested))
> >                 return -EACCES;
>
> I think so, it would be bad not to return an error in this case (and
> the similar one below).

Makes sense... will send a v2 right away.

>
> > >
> > >       rcu_read_lock();
> > >
> > > @@ -1149,7 +1149,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,
> > >       int rc = 0;
> > >       u32 denied;
> > >
> > > -     BUG_ON(!requested);
> > > +     WARN_ON(!requested);
> >
> > And likewise
> >
> > >
> > >       rcu_read_lock();
> > >
> > >
>
> --
> paul moore
> www.paul-moore.com

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Associate Software Engineer, Security Technologies
Red Hat, Inc.

      reply	other threads:[~2019-01-28 15:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-26 10:18 [PATCH] selinux: replace BUG_ONs with WARN_ONs in avc.c Ondrej Mosnacek
2019-01-28 13:26 ` Stephen Smalley
2019-01-28 15:11   ` Paul Moore
2019-01-28 15:43     ` Ondrej Mosnacek [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=CAFqZXNsVOZi9DO9qgdvmhgtw2iKxXovpdjLzYkuLJ2M72jyVaA@mail.gmail.com \
    --to=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    /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).