linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>
Subject: Re: x86/microcode: use-after-free after cpu offline/online
Date: Wed, 25 Jan 2017 22:14:50 +0300	[thread overview]
Message-ID: <16165aad-5990-51f9-4dc7-c4b68597a4d5@virtuozzo.com> (raw)
In-Reply-To: <20170125172321.fpy6cswq3ibqvfgo@pd.tnic>

On 01/25/2017 08:23 PM, Borislav Petkov wrote:
> On Wed, Jan 25, 2017 at 07:58:39PM +0300, Andrey Ryabinin wrote:
>> On 4.10-rc5 
>>    # echo 0 > /sys/devices/system/cpu/cpu1/online
>>    # echo 1 > /sys/devices/system/cpu/cpu1/online
>>
>> triggers use-after-free (probably caused by 06b8534cb72 "x86/microcode: Rework microcode loading").
>>
>>  __load_ucode_intel() accesses initrd which is obviously gone at this point:
> 
> Does that help?

Yup.
Tested-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

> 
> ---
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index 2af69d27da62..fdbf8d29ffcf 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -248,8 +248,12 @@ struct cpio_data find_microcode_in_initrd(const char *path, bool use_pa)
>  	 * possibly relocates the ramdisk. In either case, initrd_start contains
>  	 * the updated address so use that instead.
>  	 */
> -	if (!use_pa && initrd_start)
> -		start = initrd_start;
> +	if (!use_pa) {
> +		if (initrd_start)
> +			start = initrd_start;
> +		else
> +			return (struct cpio_data){ NULL, 0, "" };
> +	}
>  
>  	return find_cpio_data(path, (void *)start, size, NULL);
>  #else /* !CONFIG_BLK_DEV_INITRD */
> 

  reply	other threads:[~2017-01-25 19:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 16:58 x86/microcode: use-after-free after cpu offline/online Andrey Ryabinin
2017-01-25 17:23 ` Borislav Petkov
2017-01-25 19:14   ` Andrey Ryabinin [this message]
2017-01-25 19:23     ` Borislav Petkov
2017-01-26 16:58       ` [PATCH] x86/microcode: Do not access the initrd after it has been freed Borislav Petkov
2017-01-27  8:14         ` Andrey Ryabinin
2017-01-27  9:09           ` Borislav Petkov
2017-01-30  8:46             ` Ingo Molnar
2017-01-30  9:35               ` Borislav Petkov
2017-01-31  7:43                 ` Ingo Molnar
2017-01-31 10:01                   ` Borislav Petkov
2017-01-31 11:31                     ` Mike Galbraith
2017-01-31 12:31                       ` Borislav Petkov
2017-01-31 17:49                         ` Borislav Petkov
2017-01-31 18:05                           ` Mike Galbraith
2017-01-31 18:03                       ` Thomas Gleixner
2017-01-31 19:25                         ` [tip:irq/urgent] x86/irq: Make irq activate operations symmetric tip-bot for Thomas Gleixner
2017-01-31 16:39                     ` [PATCH] x86/microcode: Do not access the initrd after it has been freed Ingo Molnar
2017-01-30  8:49         ` [tip:x86/microcode] " tip-bot 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=16165aad-5990-51f9-4dc7-c4b68597a4d5@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).