All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>, xen-devel@lists.xen.org
Cc: Huaitong Han <huaitong.han@intel.com>
Subject: Re: [PATCH] x86/cpuidle: prevent out of bounds array access
Date: Fri, 22 May 2015 13:57:00 +0100	[thread overview]
Message-ID: <555F279C.9040905@citrix.com> (raw)
In-Reply-To: <555F41C1020000780007D4AD@mail.emea.novell.com>

On 22/05/15 13:48, Jan Beulich wrote:
> ... resulting from fbeef5570c ("x86/cpuidle: get accurate C0 value with
> xenpm tool").
>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

This appears to fix the issue.

However, looking at the other cases which play the same games, 0 is used
in preference to -1, given a zero last_state.  It would seem logical to
follow suit here (although it is just a debugkey so I am not overly fussed).

~Andrew

>
> --- a/xen/arch/x86/acpi/cpu_idle.c
> +++ b/xen/arch/x86/acpi/cpu_idle.c
> @@ -279,7 +279,7 @@ static void print_acpi_power(
>      uint64_t usage[ACPI_PROCESSOR_MAX_POWER] = { 0 };
>      uint64_t res_tick[ACPI_PROCESSOR_MAX_POWER] = { 0 };
>      unsigned int i;
> -    u8 last_state_idx;
> +    signed int last_state_idx;
>  
>      printk("==cpu%d==\n", cpu);
>      last_state_idx = power->last_state ? power->last_state->idx : -1;
> @@ -298,8 +298,12 @@ static void print_acpi_power(
>      last_state_update_tick = power->last_state_update_tick;
>      spin_unlock_irq(&power->stat_lock);
>  
> -    res_tick[last_state_idx] += ticks_elapsed(last_state_update_tick, current_tick);
> -    usage[last_state_idx]++;
> +    if ( last_state_idx >= 0 )
> +    {
> +        res_tick[last_state_idx] += ticks_elapsed(last_state_update_tick,
> +                                                  current_tick);
> +        usage[last_state_idx]++;
> +    }
>  
>      for ( i = 1; i < power->count; i++ )
>      {
>
>
>

  reply	other threads:[~2015-05-22 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  9:39 [V7] x86/cpuidle: get accurate C0 value with xenpm tool Huaitong Han
2015-05-22 12:28 ` Andrew Cooper
2015-05-22 12:48   ` [PATCH] x86/cpuidle: prevent out of bounds array access Jan Beulich
2015-05-22 12:57     ` Andrew Cooper [this message]
2015-05-22 13:48       ` Jan Beulich
2015-05-22 13:55       ` [PATCH v2] " Jan Beulich
2015-05-22 14:01         ` 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=555F279C.9040905@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=huaitong.han@intel.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.