From: Ashok Raj Date: Mon, 30 Jan 2023 21:39:48 +0000 (-0800) Subject: x86/microcode: Allow only "1" as a late reload trigger value X-Git-Tag: v6.6.7~3514^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25d0dc4b957cc8674f8554e85f18a00467e876d7;p=platform%2Fkernel%2Flinux-starfive.git x86/microcode: Allow only "1" as a late reload trigger value Microcode gets reloaded late only if "1" is written to the reload file. However, the code silently treats any other unsigned integer as a successful write even though no actions are performed to load microcode. Make the loader more strict to accept only "1" as a trigger value and return an error otherwise. [ bp: Massage commit message. ] Suggested-by: Thomas Gleixner Signed-off-by: Ashok Raj Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20230130213955.6046-3-ashok.raj@intel.com --- diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 61d57d9..fdd1e7e 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -475,11 +475,8 @@ static ssize_t reload_store(struct device *dev, ssize_t ret = 0; ret = kstrtoul(buf, 0, &val); - if (ret) - return ret; - - if (val != 1) - return size; + if (ret || val != 1) + return -EINVAL; cpus_read_lock();