All of lore.kernel.org
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] tools/x86/kcpuid: Check last token too
Date: Tue, 16 Mar 2021 15:34:39 +0800	[thread overview]
Message-ID: <20210316073439.GB49151@shbuild999.sh.intel.com> (raw)
In-Reply-To: <20210315125901.30315-1-bp@alien8.de>

On Mon, Mar 15, 2021 at 01:59:00PM +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> Input lines like
> 
>   0x8000001E,     0, EAX,   31:0, Extended APIC ID
> 
> where the short name is missing lead to a segfault because the loop
> takes the long name for the short name and tokens[5] becomes NULL which
> explodes later in strcpy().
> 
> Check its value too before further processing.
 
Thanks for the fix!

Acked-by: Feng Tang <feng.tang@intel.com>

> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
>  tools/arch/x86/kcpuid/kcpuid.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
> index 6048da34fcc6..dae75511fef7 100644
> --- a/tools/arch/x86/kcpuid/kcpuid.c
> +++ b/tools/arch/x86/kcpuid/kcpuid.c
> @@ -324,6 +324,8 @@ static int parse_line(char *line)
>  		str = NULL;
>  	}
>  	tokens[5] = strtok(str, "\n");
> +	if (!tokens[5])
> +		goto err_exit;
>  
>  	/* index/main-leaf */
>  	index = strtoull(tokens[0], NULL, 0);
> -- 
> 2.29.2

  parent reply	other threads:[~2021-03-16  7:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 12:59 [PATCH 1/2] tools/x86/kcpuid: Check last token too Borislav Petkov
2021-03-15 12:59 ` [PATCH 2/2] tools/x86/kcpuid: Add AMD leaf 0x8000001E Borislav Petkov
2021-03-16  7:42   ` Feng Tang
2021-03-16 14:28     ` Borislav Petkov
2021-03-16 17:04       ` Sean Christopherson
2021-03-17  0:30         ` Feng Tang
2021-03-18 10:38   ` [tip: x86/misc] " tip-bot2 for Borislav Petkov
2021-03-16  7:34 ` Feng Tang [this message]
2021-03-18 10:38 ` [tip: x86/misc] tools/x86/kcpuid: Check last token too tip-bot2 for 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=20210316073439.GB49151@shbuild999.sh.intel.com \
    --to=feng.tang@intel.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.