lkml.org 
[lkml]   [2021]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] tools/x86: Add a kcpuid tool to show raw CPU features
On Tue, Jan 19, 2021 at 01:19:42PM +0800, Feng Tang wrote:
> Sorry, after testing on more platforms, the following is needed to fix
> a potential array overflow ((a full patch with fix is also attached)
>
> diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
> index 3ea607b..bf68335 100644
> --- a/tools/arch/x86/kcpuid/kcpuid.c
> +++ b/tools/arch/x86/kcpuid/kcpuid.c
> @@ -329,7 +329,8 @@ static int parse_line(char *line)
> range = leafs_basic;
>
> index &= 0x7FFFFFFF;
> - if ((int)index > range->nr)
> + /* range->nr equals to max index plus 1 */
> + if ((int)index >= range->nr)

That comment is basically repeating the code. What it should do is
explain *why* that test is being done or not be there at all.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

\
 
 \ /
  Last update: 2021-01-19 14:11    [W:0.054 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site