Message ID | 1441078184-105038-1-git-send-email-wangnan0@huawei.com |
---|---|
State | Superseded |
Headers | show |
On Tue, 01 Sep, at 03:29:44AM, Wang Nan wrote: > There is a problem in dwarf-regs.c of sh, sparc and x86 that it is > possible to make an out-of-bound array accessing when searching > register names. This patch fixes it by replacing '<=' to '<', so when > register (number == XXX_MAX_REGS), get_arch_regstr() returns NULL. > > Signed-off-by: Wang Nan <wangnan0@huawei.com> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com> > Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> > Cc: David S. Miller <davem@davemloft.net> > Cc: Matt Fleming <matt@console-pimps.org> > Cc: Jiri Olsa <jolsa@kernel.org> > --- > tools/perf/arch/sh/util/dwarf-regs.c | 2 +- > tools/perf/arch/sparc/util/dwarf-regs.c | 2 +- > tools/perf/arch/x86/util/dwarf-regs.c | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) Hmm, I wonder how that bug was introduced. I guess copy and paste is probably to blame. Good catch. Reviewed-by: Matt Fleming <matt.fleming@intel.com>
On Tue, Sep 01, 2015 at 03:29:44AM +0000, Wang Nan wrote: > There is a problem in dwarf-regs.c of sh, sparc and x86 that it is > possible to make an out-of-bound array accessing when searching > register names. This patch fixes it by replacing '<=' to '<', so when > register (number == XXX_MAX_REGS), get_arch_regstr() returns NULL. > Acked-by: Jiri Olsa <jolsa@kernel.org> thanks, jirka -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
> From: Wang Nan [mailto:wangnan0@huawei.com] > > There is a problem in dwarf-regs.c of sh, sparc and x86 that it is > possible to make an out-of-bound array accessing when searching > register names. This patch fixes it by replacing '<=' to '<', so when > register (number == XXX_MAX_REGS), get_arch_regstr() returns NULL. Oops, right! Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Thank you! > > Signed-off-by: Wang Nan <wangnan0@huawei.com> > Cc: Arnaldo Carvalho de Melo <acme@redhat.com> > Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> > Cc: David S. Miller <davem@davemloft.net> > Cc: Matt Fleming <matt@console-pimps.org> > Cc: Jiri Olsa <jolsa@kernel.org> > --- > tools/perf/arch/sh/util/dwarf-regs.c | 2 +- > tools/perf/arch/sparc/util/dwarf-regs.c | 2 +- > tools/perf/arch/x86/util/dwarf-regs.c | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/arch/sh/util/dwarf-regs.c b/tools/perf/arch/sh/util/dwarf-regs.c > index 0d0897f..f8dfa89 100644 > --- a/tools/perf/arch/sh/util/dwarf-regs.c > +++ b/tools/perf/arch/sh/util/dwarf-regs.c > @@ -51,5 +51,5 @@ const char *sh_regs_table[SH_MAX_REGS] = { > /* Return architecture dependent register string (for kprobe-tracer) */ > const char *get_arch_regstr(unsigned int n) > { > - return (n <= SH_MAX_REGS) ? sh_regs_table[n] : NULL; > + return (n < SH_MAX_REGS) ? sh_regs_table[n] : NULL; > } > diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c > index 92eda41..b704fdb 100644 > --- a/tools/perf/arch/sparc/util/dwarf-regs.c > +++ b/tools/perf/arch/sparc/util/dwarf-regs.c > @@ -39,5 +39,5 @@ const char *sparc_regs_table[SPARC_MAX_REGS] = { > */ > const char *get_arch_regstr(unsigned int n) > { > - return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; > + return (n < SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; > } > diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c > index be22dd4..a08de0a 100644 > --- a/tools/perf/arch/x86/util/dwarf-regs.c > +++ b/tools/perf/arch/x86/util/dwarf-regs.c > @@ -71,5 +71,5 @@ const char *x86_64_regs_table[X86_64_MAX_REGS] = { > /* Return architecture dependent register string (for kprobe-tracer) */ > const char *get_arch_regstr(unsigned int n) > { > - return (n <= ARCH_MAX_REGS) ? arch_regs_table[n] : NULL; > + return (n < ARCH_MAX_REGS) ? arch_regs_table[n] : NULL; > } > -- > 1.8.3.4
diff --git a/tools/perf/arch/sh/util/dwarf-regs.c b/tools/perf/arch/sh/util/dwarf-regs.c index 0d0897f..f8dfa89 100644 --- a/tools/perf/arch/sh/util/dwarf-regs.c +++ b/tools/perf/arch/sh/util/dwarf-regs.c @@ -51,5 +51,5 @@ const char *sh_regs_table[SH_MAX_REGS] = { /* Return architecture dependent register string (for kprobe-tracer) */ const char *get_arch_regstr(unsigned int n) { - return (n <= SH_MAX_REGS) ? sh_regs_table[n] : NULL; + return (n < SH_MAX_REGS) ? sh_regs_table[n] : NULL; } diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c index 92eda41..b704fdb 100644 --- a/tools/perf/arch/sparc/util/dwarf-regs.c +++ b/tools/perf/arch/sparc/util/dwarf-regs.c @@ -39,5 +39,5 @@ const char *sparc_regs_table[SPARC_MAX_REGS] = { */ const char *get_arch_regstr(unsigned int n) { - return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; + return (n < SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; } diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c index be22dd4..a08de0a 100644 --- a/tools/perf/arch/x86/util/dwarf-regs.c +++ b/tools/perf/arch/x86/util/dwarf-regs.c @@ -71,5 +71,5 @@ const char *x86_64_regs_table[X86_64_MAX_REGS] = { /* Return architecture dependent register string (for kprobe-tracer) */ const char *get_arch_regstr(unsigned int n) { - return (n <= ARCH_MAX_REGS) ? arch_regs_table[n] : NULL; + return (n < ARCH_MAX_REGS) ? arch_regs_table[n] : NULL; }
There is a problem in dwarf-regs.c of sh, sparc and x86 that it is possible to make an out-of-bound array accessing when searching register names. This patch fixes it by replacing '<=' to '<', so when register (number == XXX_MAX_REGS), get_arch_regstr() returns NULL. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David S. Miller <davem@davemloft.net> Cc: Matt Fleming <matt@console-pimps.org> Cc: Jiri Olsa <jolsa@kernel.org> --- tools/perf/arch/sh/util/dwarf-regs.c | 2 +- tools/perf/arch/sparc/util/dwarf-regs.c | 2 +- tools/perf/arch/x86/util/dwarf-regs.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)