mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Jann Horn <jannh@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH] x86/microcode: Refactor Intel microcode loading
Date: Thu, 4 Apr 2019 18:27:53 +0200	[thread overview]
Message-ID: <20190404162753.GG22539@zn.tnic> (raw)
In-Reply-To: <20190404111128.131157-1-jannh@google.com>

On Thu, Apr 04, 2019 at 01:11:28PM +0200, Jann Horn wrote:
> This changes generic_load_microcode() to use the iov_iter API instead of
> an open-coded version. This allows us to avoid explicitly casting between
> user and kernel pointers.
> 
> Because the iov_iter API makes it hard to read the same location twice, as
> a side effect, this also fixes a double-read of the microcode header (which
> could e.g. lead to out-of-bounds reads in microcode_sanity_check()).
> Not that it matters much, only root can do this anyway...
> 
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
> I have tested that with this patch applied, microcode loading still works
> both via "iucode-tool -k" and via
> /sys/devices/system/cpu/microcode/reload.

Yeah, this cannot have worked because I think I broke it recently and
you'd need this:

---
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 5260185cbf7b..8a4a7823451a 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -418,8 +418,9 @@ static int do_microcode_update(const void __user *buf, size_t size)
                if (ustate == UCODE_ERROR) {
                        error = -1;
                        break;
-               } else if (ustate == UCODE_OK)
+               } else if (ustate == UCODE_NEW) {
                        apply_microcode_on_target(cpu);
+               }
        }
 
        return error;
---

Regardless, I'll take care of it. Thanks a lot for doing this cleanup,
it looks really cool and nicely clean - exactly how I envisioned it. :-)

I'll test it more later with the above fix and apply it.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  reply	other threads:[~2019-04-04 16:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 11:11 Jann Horn
2019-04-04 16:27 ` Borislav Petkov [this message]
2019-04-04 16:31   ` Jann Horn
2019-04-04 16:47     ` Borislav Petkov
2019-04-04 22:54       ` Jann Horn
2019-04-05  4:10         ` Borislav Petkov
2019-04-10 20:49 ` [tip:x86/microcode] x86/microcode/intel: Refactor Intel microcode blob loading tip-bot for Jann Horn

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=20190404162753.GG22539@zn.tnic \
    --to=bp@alien8.de \
    --cc=David.Laight@aculab.com \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®