Commit 0460534b authored by Vaibhav Jain's avatar Vaibhav Jain Committed by Michael Ellerman

powerpc/papr_scm: Limit the readability of 'perf_stats' sysfs attribute

The newly introduced 'perf_stats' attribute uses the default access
mode of 0444, allowing non-root users to access performance stats of
an nvdimm and potentially force the kernel into issuing a large number
of expensive hypercalls. Since the information exposed by this
attribute cannot be cached it is better to ward off access to this
attribute from users who don't need to access to these performance
statistics.

Hence update the access mode of 'perf_stats' attribute to be only
readable by root users.

Fixes: 2d02bf83 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
Reported-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: default avatarVaibhav Jain <vaibhav@linux.ibm.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200907110540.21349-1-vaibhav@linux.ibm.com
parent 1d3ee7df
...@@ -822,7 +822,7 @@ static ssize_t perf_stats_show(struct device *dev, ...@@ -822,7 +822,7 @@ static ssize_t perf_stats_show(struct device *dev,
kfree(stats); kfree(stats);
return rc ? rc : seq_buf_used(&s); return rc ? rc : seq_buf_used(&s);
} }
DEVICE_ATTR_RO(perf_stats); DEVICE_ATTR_ADMIN_RO(perf_stats);
static ssize_t flags_show(struct device *dev, static ssize_t flags_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment