Skip to contentSkip to conversation

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

PATCH Applied Boris Ostrovsky 3 participants 3 messages Jan 28, 2015 – Jan 29, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/core.c +1 -1
index 15c2909..36a8361 100644
@@ -552,7 +552,7 @@ static int __init microcode_init(void)
 	int error;
 
 	if (paravirt_enabled() || dis_ucode_ldr)
-		return 0;
+		return -EINVAL;
 
 	if (c->x86_vendor == X86_VENDOR_INTEL)
 		microcode_ops = init_intel_microcode();
Signature · 1 line
1.9.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Boris Ostrovsky

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.

Quoted 6 lines

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

Applied, thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#2 lore raw
In reply to Boris Ostrovsky
x86, microcode: Return error from driver init code when loader is disabled
Commit-ID:  da63865a01c6384d459464e5165d95d4f04878d8
Gitweb:     http://git.kernel.org/tip/da63865a01c6384d459464e5165d95d4f04878d8
Author:     Boris Ostrovsky <[email protected]>
AuthorDate: Tue, 27 Jan 2015 21:21:09 -0500
Committer:  Borislav Petkov <[email protected]>
CommitDate: Wed, 28 Jan 2015 09:23:40 +0100

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

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.

---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/core.c +1 -1
index 15c2909..36a8361 100644
@@ -552,7 +552,7 @@ static int __init microcode_init(void)
 	int error;
 
 	if (paravirt_enabled() || dis_ucode_ldr)
-		return 0;
+		return -EINVAL;
 
 	if (c->x86_vendor == X86_VENDOR_INTEL)
 		microcode_ops = init_intel_microcode();