Re: [PATCH] perf dwarf-regs: s390: Fix an off by one bug

"Linus Probert" <[email protected]>
Newsgroups org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users
Message-ID <[email protected]>
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 <[email protected]>
> ---
>  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.