All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH] tools: Fix wild memory allocations from c/s 250f0b4 and 85d78b4
Date: Mon, 18 May 2015 10:34:22 -0400	[thread overview]
Message-ID: <5559F86E.30302@oracle.com> (raw)
In-Reply-To: <5559F287.2060202@citrix.com>

On 05/18/2015 10:09 AM, Andrew Cooper wrote:
> On 18/05/15 15:00, Boris Ostrovsky wrote:
>> On 05/18/2015 08:57 AM, Andrew Cooper wrote:
>>> These changesets cause the respective libxc functions to unconditonally
>>> dereference their max_cpus/nodes parameters as part of initial memory
>>> allocations.  It will fail at obtaining the correct number of
>>> cpus/nodes from
>>> Xen, as the guest handles will not be NULL.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> CC: Ian Campbell <Ian.Campbell@citrix.com>
>>> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
>>> CC: Wei Liu <wei.liu2@citrix.com>
>>> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>>>
>>> ---
>>> Spotted by XenServers Coverity run.
>>> ---
>>>    tools/libxl/libxl.c               |    4 ++--
>>>    tools/misc/xenpm.c                |    4 ++--
>>>    tools/python/xen/lowlevel/xc/xc.c |    4 ++--
>>>    3 files changed, 6 insertions(+), 6 deletions(-)
>> xenpm bug is already fixed (commit
>> b315cd9cce5b6da7ca89b2d7bad3fb01e7716044 n the staging tree).
>>
>> I am not sure I understand why Coverity complains about other spots.
>> For example, in libxl_get_cpu_topology() num_cpus can be left
>> uninitialized only if xc_cputopoinfo(ctx->xch, &num_cpus, NULL) fails,
>> in which case we go to 'GC_FREE;  return ret;', so it's not ever used.
> xc_cputopoinfo(ctx->xch, &num_cpus, NULL) unconditionally dereferences
> and reads &num_cpus, and performs a memory allocation based on the result.

Ah, OK. xc_cputopoinf() (or, rather, the hypervisor) actually doesn't 
use the value of dereferenced num_cpus in this case but obviously 
Coverity can't know about this.

So Coverity cross-checks routines to see how callers use the arguments?

-boris

  reply	other threads:[~2015-05-18 14:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 12:57 [PATCH] tools: Fix wild memory allocations from c/s 250f0b4 and 85d78b4 Andrew Cooper
2015-05-18 13:03 ` Wei Liu
2015-05-21 14:53   ` Ian Campbell
2015-05-18 14:00 ` Boris Ostrovsky
2015-05-18 14:09   ` Andrew Cooper
2015-05-18 14:34     ` Boris Ostrovsky [this message]
2015-05-18 14:48       ` Andrew Cooper

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=5559F86E.30302@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.