xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v2] libxc: fix out of range shift in populate_acpi_pages
Date: Wed, 28 Sep 2016 16:54:00 +0100	[thread overview]
Message-ID: <20160928155400.GA1142@citrix.com> (raw)
In-Reply-To: <1475077099-1245-1-git-send-email-wei.liu2@citrix.com>

On Wed, Sep 28, 2016 at 04:38:19PM +0100, Wei Liu wrote:
> unsigned int is only 4-byte long and "4" is treated as int. The shift
> would overflow.
> 
> Use unsigned long type, calculate the bits to shift before shifting
> instead of shifting twice.
> 
> Caught by clang compilation test.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
>  tools/libxc/xc_dom_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
> index 87b450c..5884cdb 100644
> --- a/tools/libxc/xc_dom_core.c
> +++ b/tools/libxc/xc_dom_core.c
> @@ -1048,7 +1048,7 @@ static int populate_acpi_pages(struct xc_dom_image *dom,
>      xc_interface *xch = dom->xch;
>      uint32_t domid = dom->guest_domid;
>      unsigned long idx;
> -    unsigned int first_high_idx = (4 << 30) >> PAGE_SHIFT; /* 4GB */
> +    unsigned long first_high_idx = 4UL << (30 - PAGE_SHIFT); /* 4GB */
>  

Ian replied on IRC "LGTM", so I've translated that to an ack and pushed
this patch to staging.

Wei.

>      for ( ; num_pages; num_pages--, extents++ )
>      {
> -- 
> 2.1.4
> 

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

      reply	other threads:[~2016-09-28 15:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 15:38 [PATCH v2] libxc: fix out of range shift in populate_acpi_pages Wei Liu
2016-09-28 15:54 ` Wei Liu [this message]

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=20160928155400.GA1142@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=ian.jackson@eu.citrix.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).