All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	xen-devel@lists.xen.org, ian.campbell@citrix.com,
	ian.jackson@eu.citrix.com
Subject: Re: [PATCH v3 1/2] libxc/xentrace: Replace xc_tbuf_set_cpu_mask with CPU mask with xc_cpumap_t instead of uint32_t
Date: Tue, 24 Jun 2014 15:35:53 +0100	[thread overview]
Message-ID: <53A98CC9.2050401@eu.citrix.com> (raw)
In-Reply-To: <1403292831-3143-2-git-send-email-konrad.wilk@oracle.com>

On 06/20/2014 08:33 PM, Konrad Rzeszutek Wilk wrote:
> @@ -906,6 +949,23 @@ static int parse_evtmask(char *arg)
>       return 0;
>   }
>
> +static int parse_cpumask(const char *arg)
> +{
> +    xc_cpumap_t map;
> +    uint32_t v, i;
> +
> +    map = malloc(sizeof(uint32_t));
> +    if ( !map )
> +        return -ENOMEM;
> +
> +    v = argtol(arg, 0);
> +    for ( i = 0; i < sizeof(uint32_t); i++ )
> +        map[i] = (v >> (i * 8)) & 0xff;
> +
> +    opts.cpu_mask = map;

Sorry for not noticing this befori.  If I'm reading this right, if 
someone sets the cpumask as a hex, then opts.cpu_mask will point to an 
area of memory only 32 bits long.  However, up in set_cpu_mask(), it 
always calls xc_tbuf_set_cpu_mask() with bits equal to xc_get_max_cpus().

On systems with more than 32 logical cpus, won't this cause a buffer 
overrun?  Should you be calling xc_cpumap_alloc() here instead of malloc()?


> @@ -937,7 +997,12 @@ static void parse_args(int argc, char **argv)
>               break;
>
>           case 'c': /* set new cpu mask for filtering*/
> -            opts.cpu_mask = argtol(optarg, 0);
> +            /* Set opts.cpu_mask later as we don't have 'xch' set yet. */
> +            if ( parse_cpumask(optarg) )

Nit: You seem to be parsing it now. :-)

  -George

  reply	other threads:[~2014-06-24 14:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 19:33 [PATCH v3] Support CPU-list parsing in xentrace Konrad Rzeszutek Wilk
2014-06-20 19:33 ` [PATCH v3 1/2] libxc/xentrace: Replace xc_tbuf_set_cpu_mask with CPU mask with xc_cpumap_t instead of uint32_t Konrad Rzeszutek Wilk
2014-06-24 14:35   ` George Dunlap [this message]
2015-02-02 22:01     ` Konrad Rzeszutek Wilk
2014-06-27 10:18   ` Ian Campbell
2014-06-20 19:33 ` [PATCH v3 2/2] xentrace: Implement cpu mask range parsing of human values (-c) Konrad Rzeszutek Wilk
2014-06-24 17:17   ` George Dunlap
2014-06-25  9:51     ` George Dunlap

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=53A98CC9.2050401@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=konrad.wilk@oracle.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.