Re: [PATCH] selinux: fix memory leak on node_ptr on error return path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Colin King (colin.king@xxxxxxxxxxxxx):
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> 
> node_ptr is not being free'd if the list allocation fails, fix
> this by kfree'ing it before exiting on the error path.
> 
> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Hi,

I'm not very familiar with this code any more, but are you sure
this is needed and doesn't cause a new bug?  It *looks* like
the avtab_insert_nonunique() actually inserts the node_ptr
into the policydb, and the policydb is the one that should
eventually free it.

> ---
>  security/selinux/ss/conditional.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> index 456e1a9..5d010ef 100644
> --- a/security/selinux/ss/conditional.c
> +++ b/security/selinux/ss/conditional.c
> @@ -332,6 +332,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
>  	list = kzalloc(sizeof(struct cond_av_list), GFP_KERNEL);
>  	if (!list) {
>  		rc = -ENOMEM;
> +		kfree(node_ptr);
>  		goto err;
>  	}
>  
> -- 
> 2.7.3
_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux