linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: trix@redhat.com
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>,
	Eric Paris <eparis@parisplace.org>,
	Ondrej Mosnacek <omosnace@redhat.com>,
	weiyongjun1@huawei.com, SElinux list <selinux@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] selinux: fix undefined return of cond_evaluate_expr
Date: Wed, 17 Jun 2020 16:51:34 -0400	[thread overview]
Message-ID: <CAHC9VhT_mAd8pkboQX1xQpxmYkFvK=HW3pUB8_UzbgnW4+=RjA@mail.gmail.com> (raw)
In-Reply-To: <CAEjxPJ5uGV-SjKL7v5J=7YYEBOjyHwK625SX8fzCrbatuB=9hg@mail.gmail.com>

On Wed, Jun 17, 2020 at 9:58 AM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
> On Wed, Jun 17, 2020 at 8:40 AM <trix@redhat.com> wrote:
> >
> > From: Tom Rix <trix@redhat.com>
> >
> > clang static analysis reports an undefined return
> >
> > security/selinux/ss/conditional.c:79:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
> >         return s[0];
> >         ^~~~~~~~~~~
> >
> > static int cond_evaluate_expr( ...
> > {
> >         u32 i;
> >         int s[COND_EXPR_MAXDEPTH];
> >
> >         for (i = 0; i < expr->len; i++)
> >           ...
> >
> >         return s[0];
> >
> > When expr->len is 0, the loop which sets s[0] never runs.
> >
> > So return -1 if the loop never runs.
> >
> > Signed-off-by: Tom Rix <trix@redhat.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
>
> clang didn't complain about the similar pattern in
> security/selinux/ss/services.c:constraint_expr_eval()?

Related question: I appreciate the work you are doing Tom, can you
share how far along you are testing the SELinux code with clang?  I
ask because it would be nice to roll all of these patches up into one
PR for Linus instead of sending multiple updates.

-- 
paul moore
www.paul-moore.com

  reply	other threads:[~2020-06-17 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 12:40 [PATCH] selinux: fix undefined return of cond_evaluate_expr trix
2020-06-17 13:58 ` Stephen Smalley
2020-06-17 20:51   ` Paul Moore [this message]
2020-06-17 21:39     ` Paul Moore

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='CAHC9VhT_mAd8pkboQX1xQpxmYkFvK=HW3pUB8_UzbgnW4+=RjA@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=eparis@parisplace.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=trix@redhat.com \
    --cc=weiyongjun1@huawei.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 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).