From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad@kernel.org>
Cc: xen-devel@lists.xenproject.org, ian.campbell@citrix.com
Subject: Re: [PATCH] xenstat: Fix buffer over-run with new_domains being negative.
Date: Tue, 10 Sep 2013 17:10:41 +0100 [thread overview]
Message-ID: <522F4481.9080209@citrix.com> (raw)
In-Reply-To: <1378825710-9563-1-git-send-email-konrad.wilk@oracle.com>
On 10/09/13 16:08, Konrad Rzeszutek Wilk wrote:
> Coverity identified this as:
> CID 1055740 Out-of-bounds read - "In xenstat_get_node:
> Out-of-bounds read from a buffer (CWE-125)"
>
> And sure enough, if xc_domain_getinfolist returns us -1, we will
> try to use it later on in the for (i = 0; i < new_domains; ..)
> loop.
>
> CC: ian.campbell@citrix.com
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> tools/xenstat/libxenstat/src/xenstat.c | 14 +++++++++-----
> 1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c
> index 104655d..e5facb8 100644
> --- a/tools/xenstat/libxenstat/src/xenstat.c
> +++ b/tools/xenstat/libxenstat/src/xenstat.c
> @@ -208,15 +208,15 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
> node->num_domains,
> DOMAIN_CHUNK_SIZE,
> domaininfo);
> + if (new_domains < 0)
> + goto err;
>
> tmp = realloc(node->domains,
> (node->num_domains + new_domains)
> * sizeof(xenstat_domain));
> - if (tmp == NULL) {
> - free(node->domains);
> - free(node);
> - return NULL;
> - }
> + if (tmp == NULL)
> + goto err;
> +
> node->domains = tmp;
>
> domain = node->domains + node->num_domains;
> @@ -280,6 +280,10 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
> }
>
> return node;
> +err:
> + free(node->domains);
> + free(node);
> + return NULL;
> }
>
> void xenstat_free_node(xenstat_node * node)
next prev parent reply other threads:[~2013-09-10 16:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 15:08 [PATCH] xenstat: Fix buffer over-run with new_domains being negative Konrad Rzeszutek Wilk
2013-09-10 16:10 ` Andrew Cooper [this message]
2013-09-13 12:32 ` Ian Campbell
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=522F4481.9080209@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=konrad@kernel.org \
--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 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.