Commit ff0d1886ef0210b5dbc08934340aaf029b59aea4

Authored by Boris Ostrovsky
Committed by Greg Kroah-Hartman
1 parent 6ea9ca8008

x86, microcode: Return error from driver init code when loader is disabled

commit da63865a01c6384d459464e5165d95d4f04878d8 upstream.

Commits 65cef1311d5d ("x86, microcode: Add a disable chicken bit") and
a18a0f6850d4 ("x86, microcode: Don't initialize microcode code on
paravirt") allow microcode driver skip initialization when microcode
loading is not permitted.

However, they don't prevent the driver from being loaded since the
init code returns 0. If at some point later the driver gets unloaded
this will result in an oops while trying to deregister the (never
registered) device.

To avoid this, make init code return an error on paravirt or when
microcode loading is disabled. The driver will then never be loaded.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: http://lkml.kernel.org/r/1422411669-25147-1-git-send-email-boris.ostrovsky@oracle.com
Reported-by: James Digwall <james@dingwall.me.uk>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

arch/x86/kernel/cpu/microcode/core.c
... ... @@ -552,7 +552,7 @@
552 552 int error;
553 553  
554 554 if (paravirt_enabled() || dis_ucode_ldr)
555   - return 0;
  555 + return -EINVAL;
556 556  
557 557 if (c->x86_vendor == X86_VENDOR_INTEL)
558 558 microcode_ops = init_intel_microcode();