From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 1/4] flask: fix memory leaks Date: Fri, 7 Feb 2014 12:51:44 +0000 Message-ID: <52F4D6E0.60305@citrix.com> References: <52F4B840020000780011A1E2@nat28.tlf.novell.com> <52F4B99C020000780011A1EE@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5842493271014130802==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WBkui-0002nq-CC for xen-devel@lists.xenproject.org; Fri, 07 Feb 2014 12:52:12 +0000 In-Reply-To: <52F4B99C020000780011A1EE@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: George Dunlap , xen-devel , dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org --===============5842493271014130802== Content-Type: multipart/alternative; boundary="------------030201030602060303090808" --------------030201030602060303090808 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 07/02/14 09:46, Jan Beulich wrote: > Plus, in the case of security_preserve_bools(), prevent double freeing > in the case of security_get_bools() failing. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/xsm/flask/flask_op.c > +++ b/xen/xsm/flask/flask_op.c > @@ -347,6 +347,7 @@ static int flask_security_set_bool(struc > > if ( arg->bool_id >= num ) > { > + xfree(values); > rv = -ENOENT; > goto out; > } > --- a/xen/xsm/flask/ss/services.c > +++ b/xen/xsm/flask/ss/services.c > @@ -1902,6 +1902,7 @@ err: > { > for ( i = 0; i < *len; i++ ) > xfree((*names)[i]); > + xfree(*names); > } > xfree(*values); > goto out; > @@ -2011,7 +2012,7 @@ static int security_preserve_bools(struc > > rc = security_get_bools(&nbools, &bnames, &bvalues, NULL); > if ( rc ) > - goto out; > + return rc; > for ( i = 0; i < nbools; i++ ) > { > booldatum = hashtab_search(p->p_bools.table, bnames[i]); > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------030201030602060303090808 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 07/02/14 09:46, Jan Beulich wrote:
Plus, in the case of security_preserve_bools(), prevent double freeing
in the case of security_get_bools() failing.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/xsm/flask/flask_op.c
+++ b/xen/xsm/flask/flask_op.c
@@ -347,6 +347,7 @@ static int flask_security_set_bool(struc
 
         if ( arg->bool_id >= num )
         {
+            xfree(values);
             rv = -ENOENT;
             goto out;
         }
--- a/xen/xsm/flask/ss/services.c
+++ b/xen/xsm/flask/ss/services.c
@@ -1902,6 +1902,7 @@ err:
     {
         for ( i = 0; i < *len; i++ )
             xfree((*names)[i]);
+        xfree(*names);
     }
     xfree(*values);
     goto out;
@@ -2011,7 +2012,7 @@ static int security_preserve_bools(struc
 
     rc = security_get_bools(&nbools, &bnames, &bvalues, NULL);
     if ( rc )
-        goto out;
+        return rc;
     for ( i = 0; i < nbools; i++ )
     {
         booldatum = hashtab_search(p->p_bools.table, bnames[i]);





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

--------------030201030602060303090808-- --===============5842493271014130802== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============5842493271014130802==--