The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Feng Tang <feng.tang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
	Dave Hansen <dave.hansen@intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	nivedita@alum.mit.edu, thomas.lendacky@amd.com,
	yazen.ghannam@amd.com, wei.huang2@amd.com
Subject: Re: [PATCH v4] tools/x86: Add a kcpuid tool to show raw CPU features
Date: Tue, 19 Jan 2021 10:11:16 +0100	[thread overview]
Message-ID: <20210119091116.GA27433@zn.tnic> (raw)
In-Reply-To: <20210119051942.GA87207@shbuild999.sh.intel.com>

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

  reply	other threads:[~2021-01-19  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18  7:35 [PATCH v4] tools/x86: Add a kcpuid tool to show raw CPU features Feng Tang
2021-01-19  5:19 ` Feng Tang
2021-01-19  9:11   ` Borislav Petkov [this message]
2021-01-19 12:56     ` Feng Tang
2021-01-19 13:10       ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210119091116.GA27433@zn.tnic \
    --to=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=feng.tang@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nivedita@alum.mit.edu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=wei.huang2@amd.com \
    --cc=x86@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox