Skip to content

Commit 3e66ef4

Browse files
lenbshiloong
authored andcommitted
powercap: restrict energy meter to root access
to #31887426 commit 949dd01 upstream. Remove non-privileged user access to power data contained in /sys/class/powercap/intel-rapl*/*/energy_uj Non-privileged users currently have read access to power data and can use this data to form a security attack. Some privileged drivers/applications need read access to this data, but don't expose it to non-privileged users. For example, thermald uses this data to ensure that power management works correctly. Thus removing non-privileged access is preferred over completely disabling this power reporting capability with CONFIG_INTEL_RAPL=n. Fixes: 95677a9 ("PowerCap: Fix mode for energy counter") Signed-off-by: Len Brown <len.brown@intel.com> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Fixes: CVE-2020-8694 Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com> Acked-by: Michael Wang <yun.wang@linux.alibaba.com>
1 parent ea53664 commit 3e66ef4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/powercap/powercap_sys.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ static void create_power_zone_common_attributes(
379379
&dev_attr_max_energy_range_uj.attr;
380380
if (power_zone->ops->get_energy_uj) {
381381
if (power_zone->ops->reset_energy_uj)
382-
dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
382+
dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUSR;
383383
else
384-
dev_attr_energy_uj.attr.mode = S_IRUGO;
384+
dev_attr_energy_uj.attr.mode = S_IRUSR;
385385
power_zone->zone_dev_attrs[count++] =
386386
&dev_attr_energy_uj.attr;
387387
}

0 commit comments

Comments
 (0)