kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] SELinux: fix error code in policydb_init()
@ 2015-01-28  6:42 Dan Carpenter
  2015-01-28  6:52 ` Serge E. Hallyn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-01-28  6:42 UTC (permalink / raw)
  To: Paul Moore
  Cc: selinux, kernel-janitors, linux-security-module, Himangi Saraogi,
	James Morris, Namhyung Kim, Stephen Smalley

If hashtab_create() returns a NULL pointer then we should return -ENOMEM
but instead the current code returns success.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index bc2a586..74aa224 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
 		goto out;
 
 	p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
-	if (!p->filename_trans)
+	if (!p->filename_trans) {
+		rc = -ENOMEM;
 		goto out;
+	}
 
 	p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
-	if (!p->range_tr)
+	if (!p->range_tr) {
+		rc = -ENOMEM;
 		goto out;
+	}
 
 	ebitmap_init(&p->filename_trans_ttypes);
 	ebitmap_init(&p->policycaps);

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

* Re: [patch] SELinux: fix error code in policydb_init()
  2015-01-28  6:42 [patch] SELinux: fix error code in policydb_init() Dan Carpenter
@ 2015-01-28  6:52 ` Serge E. Hallyn
  2015-01-28 15:14 ` Stephen Smalley
  2015-01-29 20:51 ` Paul Moore
  2 siblings, 0 replies; 4+ messages in thread
From: Serge E. Hallyn @ 2015-01-28  6:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: kernel-janitors, linux-security-module, Himangi Saraogi,
	James Morris, Namhyung Kim, Stephen Smalley, selinux

Quoting Dan Carpenter (dan.carpenter@oracle.com):
> If hashtab_create() returns a NULL pointer then we should return -ENOMEM
> but instead the current code returns success.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>

> 
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index bc2a586..74aa224 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
>  		goto out;
>  
>  	p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
> -	if (!p->filename_trans)
> +	if (!p->filename_trans) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
>  
>  	p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
> -	if (!p->range_tr)
> +	if (!p->range_tr) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
>  
>  	ebitmap_init(&p->filename_trans_ttypes);
>  	ebitmap_init(&p->policycaps);

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

* Re: [patch] SELinux: fix error code in policydb_init()
  2015-01-28  6:42 [patch] SELinux: fix error code in policydb_init() Dan Carpenter
  2015-01-28  6:52 ` Serge E. Hallyn
@ 2015-01-28 15:14 ` Stephen Smalley
  2015-01-29 20:51 ` Paul Moore
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Smalley @ 2015-01-28 15:14 UTC (permalink / raw)
  To: Dan Carpenter, Paul Moore
  Cc: James Morris, kernel-janitors, linux-security-module,
	Himangi Saraogi, selinux, Namhyung Kim

On 01/28/2015 01:42 AM, Dan Carpenter wrote:
> If hashtab_create() returns a NULL pointer then we should return -ENOMEM
> but instead the current code returns success.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>

> 
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index bc2a586..74aa224 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
>  		goto out;
>  
>  	p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
> -	if (!p->filename_trans)
> +	if (!p->filename_trans) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
>  
>  	p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
> -	if (!p->range_tr)
> +	if (!p->range_tr) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
>  
>  	ebitmap_init(&p->filename_trans_ttypes);
>  	ebitmap_init(&p->policycaps);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [patch] SELinux: fix error code in policydb_init()
  2015-01-28  6:42 [patch] SELinux: fix error code in policydb_init() Dan Carpenter
  2015-01-28  6:52 ` Serge E. Hallyn
  2015-01-28 15:14 ` Stephen Smalley
@ 2015-01-29 20:51 ` Paul Moore
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2015-01-29 20:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: selinux, kernel-janitors, linux-security-module, Himangi Saraogi,
	James Morris, Namhyung Kim, Stephen Smalley

On Wednesday, January 28, 2015 09:42:39 AM Dan Carpenter wrote:
> If hashtab_create() returns a NULL pointer then we should return -ENOMEM
> but instead the current code returns success.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Merged.  Nice catch, thanks for submitting.

> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index bc2a586..74aa224 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
>  		goto out;
> 
>  	p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 <<
> 10)); -	if (!p->filename_trans)
> +	if (!p->filename_trans) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
> 
>  	p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
> -	if (!p->range_tr)
> +	if (!p->range_tr) {
> +		rc = -ENOMEM;
>  		goto out;
> +	}
> 
>  	ebitmap_init(&p->filename_trans_ttypes);
>  	ebitmap_init(&p->policycaps);

-- 
paul moore
www.paul-moore.com


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

end of thread, other threads:[~2015-01-29 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-28  6:42 [patch] SELinux: fix error code in policydb_init() Dan Carpenter
2015-01-28  6:52 ` Serge E. Hallyn
2015-01-28 15:14 ` Stephen Smalley
2015-01-29 20:51 ` 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).