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: Dan Carpenter <dan.carpenter@oracle.com>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	Eric Paris <eparis@parisplace.org>,
	Jeff Vander Stoep <jeffv@google.com>,
	SElinux list <selinux@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH -next] selinux: fix error return code in policydb_read()
Date: Fri, 1 May 2020 21:52:15 +0200	[thread overview]
Message-ID: <CAFqZXNthwrGDOWei-8ET8A-3sE+Ecg3DquHy-EB2YCmDtHAaWg@mail.gmail.com> (raw)
In-Reply-To: <CAHC9VhTxDkrLP4nvwsUTZDNiLPQJn0=gqTr609MCTrXQU40arw@mail.gmail.com>

On Fri, May 1, 2020 at 9:08 PM Paul Moore <paul@paul-moore.com> wrote:
> On Wed, Apr 29, 2020 at 9:32 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > On Wed, Apr 29, 2020 at 3:15 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > On Wed, Apr 29, 2020 at 07:30:53AM +0000, Wei Yongjun wrote:
> > > > Fix to return negative error code -ENOMEM from the kvcalloc() error
> > > > handling case instead of 0, as done elsewhere in this function.
> > > >
> > >
> > > Please add a Fixes tag and Cc Kent.
> > >
> > > Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
> > >
> > >
> > > > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > > > ---
> > > >  security/selinux/ss/policydb.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> > > > index a0b3dc152468..a51e051df2cc 100644
> > > > --- a/security/selinux/ss/policydb.c
> > > > +++ b/security/selinux/ss/policydb.c
> > > > @@ -2638,6 +2638,7 @@ int policydb_read(struct policydb *p, void *fp)
> > > >       if (rc)
> > > >               goto bad;
> > > >
> > > > +     rc = -ENOMEM;
> > > >       p->type_attr_map_array = kvcalloc(p->p_types.nprim,
> > > >                                         sizeof(*p->type_attr_map_array),
> > > >                                         GFP_KERNEL);
> > >
> > > There is another bug earlier in the function as well:
> > >
> > > security/selinux/ss/policydb.c
> > >   2537
> > >   2538          rc = next_entry(buf, fp, sizeof(u32));
> > >   2539          if (rc)
> > >   2540                  goto bad;
> > >   2541          nel = le32_to_cpu(buf[0]);
> > >   2542
> > >   2543          p->role_tr = hashtab_create(role_trans_hash, role_trans_cmp, nel);
> > >   2544          if (!p->role_tr)
> > >   2545                  goto bad;
> > >                         ^^^^^^^^
> > >
> > >   2546          for (i = 0; i < nel; i++) {
> > >   2547                  rc = -ENOMEM;
> > >
> > > This style of setting the error code seems very bug prone.
> > >
> > > The Fixes tag for this one is:
> > > Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table")
> >
> > FYI, this one is also indirectly fixed by this patch, which is
> > currently pending review:
> > https://patchwork.kernel.org/patch/11514495/
>
> If we know the code is broken, let's fix it independently of a feature
> patch.  Ondrej, I believe the original patch is yours so please send
> me a new patch with just the fix, thank you.

Sure, here you go:
https://lore.kernel.org/selinux/20200501195111.3335258-1-omosnace@redhat.com/T/

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


  reply	other threads:[~2020-05-01 19:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  7:30 [PATCH -next] selinux: fix error return code in policydb_read() Wei Yongjun
2020-04-29 13:07 ` Dan Carpenter
2020-04-29 13:32   ` Ondrej Mosnacek
2020-04-29 13:47     ` Dan Carpenter
2020-05-01 19:08     ` Paul Moore
2020-05-01 19:52       ` Ondrej Mosnacek [this message]
2020-05-01 16:46   ` Paul Moore
2020-05-04 19:17     ` Dan Carpenter
2020-05-01 19:04 ` Paul Moore
  -- strict thread matches above, loose matches on Subject: below --
2019-01-18 14:23 [PATCH -next] selinux: Fix " Wei Yongjun
2019-01-18 21:28 ` Paul Moore
2019-01-19  0:21   ` Stephen Rothwell
2019-01-20 20:04     ` Stephen Rothwell
2019-01-22 17:39       ` Paul Moore
2019-01-25 21:59         ` Paul Moore
2016-09-10  7:43 [PATCH -next] SELinux: fix " Wei Yongjun
2016-09-13 21:19 ` 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=CAFqZXNthwrGDOWei-8ET8A-3sE+Ecg3DquHy-EB2YCmDtHAaWg@mail.gmail.com \
    --to=omosnace@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=eparis@parisplace.org \
    --cc=jeffv@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.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).