perf dwarf: Fix potential array out of bounds access
authorWang Nan <wangnan0@huawei.com>
Tue, 1 Sep 2015 03:29:44 +0000 (03:29 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 1 Sep 2015 14:33:48 +0000 (11:33 -0300)
commit3b27d13940c3710a1128527c43719cb0bb05d73b
tree88847c3a13e7c792c0416be0c6186d903fb57d2c
parent532026612455a4a6fd27c1b2e7111263f63218a2
perf dwarf: Fix potential array out of bounds access

There is a problem in the dwarf-regs.c files for sh, sparc and x86 where
it is possible to make an out-of-bounds array access when searching for
register names.

This patch fixes it by replacing '<=' to '<', so when register (number
== XXX_MAX_REGS), get_arch_regstr() will return NULL.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Reviewed-by: Matt Fleming <matt@console-pimps.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@huawei.com
Link: http://lkml.kernel.org/r/1441078184-105038-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/sh/util/dwarf-regs.c
tools/perf/arch/sparc/util/dwarf-regs.c
tools/perf/arch/x86/util/dwarf-regs.c