perf dwarf-regs: s390: Fix an off by one bug
Subsystems (2)
PATCH 1/1 perf dwarf-regs: s390: Fix an off by one bug
Change the > comparison to >= to prevent an out of bounds access of the dwarf_s390_regnums[] array.
--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1 -1
@@ -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 ;
Signature · 1 line
2.53.0
Quoted 14 lines · Dan Carpenter
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 <[email protected]>--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 51
Quoted 8 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1
-1@@ -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 ;
Signature · 9 lines
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
Ian Rogers
reviewerQuoted 15 lines · Dan Carpenter
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 <[email protected]>--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 48
Quoted 5 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1
-1@@ -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
Quoted 6 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-1dwarf_s390_regnums[perf_regnum] == 0)return -ENOENT ; --2.53.0
Quoted 27 lines · Ian Rogers
Quoted 15 lines · Dan Carpenter
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 <[email protected]>--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 48
Quoted 5 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1
-1@@ -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
Quoted 1 line
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
Ian Rogers
reviewerQuoted 29 lines · Dan Carpenter
Quoted 27 lines · Ian Rogers
Quoted 15 lines · Dan Carpenter
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 <[email protected]>--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 48
Quoted 5 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1
-1@@ -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
Quoted 4 lines
Quoted 1 line
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
Quoted 3 lines
regards,
dan carpenter
Quoted 14 lines · Dan Carpenter
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 <[email protected]>--- tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c | 1 +- 1 files changed, 1 insertions(+), 1 deletions(-)tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 48
Quoted 5 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +1
-1@@ -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?
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c int __get_dwarf_regnum_for_perf_regnum_s390(int perf_regnum) · line 51
Quoted 3 lines
tools/perf/util/dwarf-regs-arch/dwarf-regs-s390.c +0
-0dwarf_s390_regnums[perf_regnum] == 0)return -ENOENT ;
Br,
Linus