[PATCH] x86/microcode: allow non-root reading of microcode version and processor flags

From: Jacek Tomaka
Date: Fri Aug 24 2018 - 23:52:27 EST


/sys/devices/system/cpu/cpuX/microcode

Before:
-r-------- processor_flags
-r-------- version

After:
-r--r--r-- processor_flags
-r--r--r-- version

Microcode version has been already readable for non root users via
/proc/cpuinfo. However it is easier to access it from
/sys/devices/system/cpu/cpuX/microcode/version

Reported-by: Tim Burgess <timb@xxxxxxx>
Signed-off-by: Jacek Tomaka <jacek.tomaka@xxxxxxxxx>
---
arch/x86/kernel/cpu/microcode/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index b9bc8a1a58..2637ff09d6 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -666,8 +666,8 @@ static ssize_t pf_show(struct device *dev,
}

static DEVICE_ATTR_WO(reload);
-static DEVICE_ATTR(version, 0400, version_show, NULL);
-static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
+static DEVICE_ATTR(version, 0444, version_show, NULL);
+static DEVICE_ATTR(processor_flags, 0444, pf_show, NULL);

static struct attribute *mc_default_attrs[] = {
&dev_attr_version.attr,
--
2.17.0