xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Dario Faggioli <dario.faggioli@citrix.com>,
	Harmandeep Kaur <write.harmandeep@gmail.com>,
	xen-devel@lists.xenproject.org,
	George Dunlap <george.dunlap@eu.citrix.com>
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com,
	stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size()
Date: Thu, 11 Feb 2016 10:11:14 +0000	[thread overview]
Message-ID: <1455185474.814.23.camel@citrix.com> (raw)
In-Reply-To: <1455184996.3148.282.camel@citrix.com>

On Thu, 2016-02-11 at 11:03 +0100, Dario Faggioli wrote:
> On Thu, 2016-02-11 at 09:52 +0000, Ian Campbell wrote:
> > On Thu, 2016-02-11 at 14:02 +0530, Harmandeep Kaur wrote:
> > >  
> > > diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
> > > index 695939a..d96cc67 100644
> > > --- a/tools/libxc/xc_tbuf.c
> > > +++ b/tools/libxc/xc_tbuf.c
> > > @@ -70,11 +70,13 @@ int xc_tbuf_get_size(xc_interface *xch,
> > > unsigned long
> > > *size)
> > >                      sysctl.u.tbuf_op.buffer_mfn);
> > >  
> > >      if ( t_info == NULL || t_info->tbuf_size == 0 )
> > > -        return -1;
> > > +        rc = -1;
> > > +    else
> > > +	*size = t_info->tbuf_size;
> > >  
> > > -    *size = t_info->tbuf_size;
> > > +    xenforeignmemory_unmap(xch->fmem, t_info, *size);
> > 
> > *size could be uninitialised here (in the error path) and even in the
> > success case I don't think t_info->tbus_size is the right argument
> > here, it
> > needs to be the size which was passed to the map function, i.e.
> > sysctl.u.tbuf_op.size.
> > 
> And I think both are issues with the current code,

I don't think so, the xenforeignmemory_unmap using *size as an argument
(where it is either uninitialised or the wrong value) is added by this
patch.

>  and, more important,
> not what Coverity is complaining about in the referenced CID?

> To be clear, I'm not arguing that they're not issues we should fix (I
> don't know about the tbuf_size vs. tbuf_op.size, but I can check). I'm
> genuinely asking whether we should do that here, as compared to in a
> pre or follow up patch, and let this one be the one that placates
> Coverity on that particular issue.

Ian.

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

  reply	other threads:[~2016-02-11 10:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11  8:32 [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size() Harmandeep Kaur
2016-02-11  9:14 ` Dario Faggioli
2016-02-11  9:52 ` Ian Campbell
2016-02-11 10:03   ` Dario Faggioli
2016-02-11 10:11     ` Ian Campbell [this message]
2016-02-11 10:23       ` Dario Faggioli

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=1455185474.814.23.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=write.harmandeep@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 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).