selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux: fix return value on error in policydb_read()
@ 2020-05-01 19:51 Ondrej Mosnacek
  2020-05-01 19:54 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Ondrej Mosnacek @ 2020-05-01 19:51 UTC (permalink / raw)
  To: selinux, Paul Moore; +Cc: Wei Yongjun, kernel-janitors, Dan Carpenter

The value of rc is still zero from the last assignment when the error
path is taken. Fix it by setting it to -ENOMEM before the
hashtab_create() call.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.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 1c0041576643..9f7ce3e037d1 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -2540,6 +2540,7 @@ int policydb_read(struct policydb *p, void *fp)
 		goto bad;
 	nel = le32_to_cpu(buf[0]);
 
+	rc = -ENOMEM;
 	p->role_tr = hashtab_create(role_trans_hash, role_trans_cmp, nel);
 	if (!p->role_tr)
 		goto bad;
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selinux: fix return value on error in policydb_read()
  2020-05-01 19:51 [PATCH] selinux: fix return value on error in policydb_read() Ondrej Mosnacek
@ 2020-05-01 19:54 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2020-05-01 19:54 UTC (permalink / raw)
  To: Ondrej Mosnacek; +Cc: selinux, Wei Yongjun, kernel-janitors, Dan Carpenter

On Fri, May 1, 2020 at 3:51 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> The value of rc is still zero from the last assignment when the error
> path is taken. Fix it by setting it to -ENOMEM before the
> hashtab_create() call.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  security/selinux/ss/policydb.c | 1 +
>  1 file changed, 1 insertion(+)

Here I was just about to reply to your other patches that patch 2/4
looked fine to me but I was going to hold off on applying it until
this patch came through :)

Merged into selinux/next, thanks.

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-01 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 19:51 [PATCH] selinux: fix return value on error in policydb_read() Ondrej Mosnacek
2020-05-01 19:54 ` Paul Moore

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).