From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>,
Paul Moore <paul@paul-moore.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: Wed, 29 Apr 2020 13:47:24 +0000 [thread overview]
Message-ID: <20200429134724.GR2014@kadam> (raw)
In-Reply-To: <CAFqZXNs=YTn-mnzSEssR1szRhSw7Ajdaqg=wy88O_F3gBL2rOQ@mail.gmail.com>
On Wed, Apr 29, 2020 at 03:32:13PM +0200, Ondrej Mosnacek 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/
>
Ah. Fantastic. Wei, could you just resend your original commit with
the first Fixes tag and Kent CC'd?
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>,
Paul Moore <paul@paul-moore.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: Wed, 29 Apr 2020 16:47:24 +0300 [thread overview]
Message-ID: <20200429134724.GR2014@kadam> (raw)
In-Reply-To: <CAFqZXNs=YTn-mnzSEssR1szRhSw7Ajdaqg=wy88O_F3gBL2rOQ@mail.gmail.com>
On Wed, Apr 29, 2020 at 03:32:13PM +0200, Ondrej Mosnacek 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/
>
Ah. Fantastic. Wei, could you just resend your original commit with
the first Fixes tag and Kent CC'd?
regards,
dan carpenter
next prev parent reply other threads:[~2020-04-29 13:47 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-18 14:23 [PATCH -next] selinux: Fix error return code in policydb_read() Wei Yongjun
2019-01-18 14:23 ` Wei Yongjun
2019-01-18 21:28 ` Paul Moore
2019-01-18 21:28 ` Paul Moore
2019-01-19 0:21 ` Stephen Rothwell
2019-01-19 0:21 ` Stephen Rothwell
2019-01-20 20:04 ` Stephen Rothwell
2019-01-20 20:04 ` Stephen Rothwell
2019-01-22 17:39 ` Paul Moore
2019-01-22 17:39 ` Paul Moore
2019-01-25 21:59 ` Paul Moore
2019-01-25 21:59 ` Paul Moore
2020-04-27 12:49 ` [PATCH -next] selinux: fix error return code in cond_read_list() Wei Yongjun
2020-04-27 12:49 ` Wei Yongjun
2020-04-27 13:32 ` Ondrej Mosnacek
2020-04-27 13:32 ` Ondrej Mosnacek
2020-04-27 21:59 ` Paul Moore
2020-04-27 21:59 ` Paul Moore
2020-04-29 7:30 ` [PATCH -next] selinux: fix error return code in policydb_read() Wei Yongjun
2020-04-29 7:30 ` Wei Yongjun
2020-04-29 13:07 ` Dan Carpenter
2020-04-29 13:07 ` Dan Carpenter
2020-04-29 13:32 ` Ondrej Mosnacek
2020-04-29 13:32 ` Ondrej Mosnacek
2020-04-29 13:47 ` Dan Carpenter [this message]
2020-04-29 13:47 ` Dan Carpenter
2020-05-01 19:08 ` Paul Moore
2020-05-01 19:08 ` Paul Moore
2020-05-01 19:52 ` Ondrej Mosnacek
2020-05-01 19:52 ` Ondrej Mosnacek
2020-05-01 16:46 ` Paul Moore
2020-05-01 16:46 ` Paul Moore
2020-05-04 19:17 ` Dan Carpenter
2020-05-04 19:17 ` Dan Carpenter
2020-05-01 19:04 ` Paul Moore
2020-05-01 19:04 ` Paul Moore
-- strict thread matches above, loose matches on Subject: below --
2016-09-10 7:43 [PATCH -next] SELinux: " 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=20200429134724.GR2014@kadam \
--to=dan.carpenter@oracle.com \
--cc=eparis@parisplace.org \
--cc=jeffv@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=omosnace@redhat.com \
--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 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.