tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Change the > comparison to >= to prevent an out of bounds access of
the dwarf_s390_regnums[] array.
Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
index 310a37451bdc..f79216a7665a 100644
--- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
+++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
@@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
if (perf_regnum == 0)
return 0;
- if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
+ if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
dwarf_s390_regnums[perf_regnum] == 0)
return -ENOENT;
--
2.53.0
On Thu Apr 23, 2026 at 9:07 AM CEST, Dan Carpenter wrote:
> Change the > comparison to >= to prevent an out of bounds access of
> the dwarf_s390_regnums[] array.
>
> Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> index 310a37451bdc..f79216a7665a 100644
> --- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> +++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> @@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
> if (perf_regnum == 0)
> return 0;
>
> - if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> + if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
^^
Why leave the two spaces?
> dwarf_s390_regnums[perf_regnum] == 0)
> return -ENOENT;
>
Br,
Linus
On Thu, Apr 23, 2026 at 12:07 AM Dan Carpenter <error27@gmail.com> wrote:
>
> Change the > comparison to >= to prevent an out of bounds access of
> the dwarf_s390_regnums[] array.
>
> Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> index 310a37451bdc..f79216a7665a 100644
> --- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> +++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> @@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
> if (perf_regnum == 0)
> return 0;
>
> - if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> + if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
It looks like this mistake was copy-pasted into these files as well:
- tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
- tools/perf/util/dwarf-regs-arch/dwarf-regs-x86.c
- tools/perf/util/dwarf-regs-arch/dwarf-regs-powerpc.c
Could you fix them all?
Thanks,
Ian
> dwarf_s390_regnums[perf_regnum] == 0)
> return -ENOENT;
>
> --
> 2.53.0
>
On Thu, Apr 23, 2026 at 01:24:50PM -0700, Ian Rogers wrote:
> On Thu, Apr 23, 2026 at 12:07 AM Dan Carpenter <error27@gmail.com> wrote:
> >
> > Change the > comparison to >= to prevent an out of bounds access of
> > the dwarf_s390_regnums[] array.
> >
> > Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > index 310a37451bdc..f79216a7665a 100644
> > --- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > +++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > @@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
> > if (perf_regnum == 0)
> > return 0;
> >
> > - if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> > + if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
>
> It looks like this mistake was copy-pasted into these files as well:
> - tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
> - tools/perf/util/dwarf-regs-arch/dwarf-regs-x86.c
> - tools/perf/util/dwarf-regs-arch/dwarf-regs-powerpc.c
>
> Could you fix them all?
Sure. Do you want that as four separate patches or just one patch with
four Fixes tags?
regards,
dan carpenter
On Thu, Apr 23, 2026 at 1:28 PM Dan Carpenter <error27@gmail.com> wrote:
>
> On Thu, Apr 23, 2026 at 01:24:50PM -0700, Ian Rogers wrote:
> > On Thu, Apr 23, 2026 at 12:07 AM Dan Carpenter <error27@gmail.com> wrote:
> > >
> > > Change the > comparison to >= to prevent an out of bounds access of
> > > the dwarf_s390_regnums[] array.
> > >
> > > Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
> > > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > > ---
> > > tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
> > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > > index 310a37451bdc..f79216a7665a 100644
> > > --- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > > +++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> > > @@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
> > > if (perf_regnum == 0)
> > > return 0;
> > >
> > > - if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> > > + if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> >
> > It looks like this mistake was copy-pasted into these files as well:
> > - tools/perf/util/dwarf-regs-arch/dwarf-regs-csky.c
> > - tools/perf/util/dwarf-regs-arch/dwarf-regs-x86.c
> > - tools/perf/util/dwarf-regs-arch/dwarf-regs-powerpc.c
> >
> > Could you fix them all?
>
> Sure. Do you want that as four separate patches or just one patch with
> four Fixes tags?
Probably the latter as it will make backports easier. Thanks!
Ian
> regards,
> dan carpenter
>
On 4/23/26 09:07, Dan Carpenter wrote:
> Change the > comparison to >= to prevent an out of bounds access of
> the dwarf_s390_regnums[] array.
>
> Fixes: 1e452dd850f3 ("perf dwarf-regs: Add S390 perf to DWARF register number mapping functions")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> index 310a37451bdc..f79216a7665a 100644
> --- a/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> +++ b/tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c
> @@ -45,7 +45,7 @@ int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum)
> if (perf_regnum == 0)
> return 0;
>
> - if (perf_regnum < 0 || perf_regnum > (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> + if (perf_regnum < 0 || perf_regnum >= (int)ARRAY_SIZE(dwarf_s390_regnums) ||
> dwarf_s390_regnums[perf_regnum] == 0)
> return -ENOENT;
>
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
© 2016 - 2026 Red Hat, Inc.