Patch applied.
thanks.

On Wed, May 4, 2011 at 12:30 AM, Corey Ashford
<cjash...@linux.vnet.ibm.com> wrote:
> Anton Blanchard discovered that when he ran a simple example of
> evt2raw on a POWER7 machine, he got a seg fault in libpfm because
> libpfm checked the size field of the perf_event_attr struct, and
> if it's non-zero, it uses that size to memset the struct to all
> zeros.  If the size is garbage (a large number), memset will write
> past the end of the structure, corrupting memory, and possibly
> causing a seg fault.
>
> This patch corrects that by initializing the size field to the
> size of the perf_event_addr_struct which is being passed in.  This
> should be the safest route.
>
> Reported-by: Anton Blanchard <an...@au1.ibm.com>
> Signed-off-by: Corey Ashford <cjash...@linux.vnet.ibm.com>
> ---
>  perf_examples/evt2raw.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/perf_examples/evt2raw.c b/perf_examples/evt2raw.c
> index 7d11598..7565ce9 100644
> --- a/perf_examples/evt2raw.c
> +++ b/perf_examples/evt2raw.c
> @@ -66,6 +66,7 @@ main(int argc, char **argv)
>                errx(1, "Internal error: pfm_initialize returned %s",
>                        pfm_strerror(ret));
>
> +       pea.size = sizeof(struct perf_event_attr);
>        ret = pfm_get_perf_event_encoding(event_str, PFM_PLM0|PFM_PLM3, &pea,
>                &fstr, NULL);
>        if (ret != PFM_SUCCESS)
> --
> 1.7.0.4
>
>

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to